Pike 8.1 widestring out-of-bounds bug

Pontus Rodling <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <[email protected]>
Hi,

I've been trying out Pike 8.1 with some projects and ran into a nasty
issue where the bbcode parsing module for a community site started
spewing out random garbage at the end of the processed data, garbage
that was somewhat different every time.

As it turns out, some operations on widestrings causes Pike to read data
outside of string memory.
This was tested in 8.1 / 407d071f2ae0.


I've managed to narrow it down to a very simple test:

Pike v8.0 release 245 running Hilfe v3.5 (Incremental Pike Frontend)
> "ABCD\u2019"[1..][1..] == "ABCD\u2019"[2..];
(1) Result: 1    // Good

Pike v8.1 release 4 running Hilfe v3.5 (Incremental Pike Frontend)
> "ABCD\u2019"[1..][1..] == "ABCD\u2019"[2..];
(1) Result: 0    // Bad



What happens is the following...

> string x = "ABCD\u2019";
> x;
(1) Result: "ABCD\u2019"
> x = x[1..];
(2) Result: "BCD\u2019"
> x = x[1..];
(3) Result: "D\u2019\0"



This happens on multiple machines with both byte-/machinecode generation.
Unfortunately I haven't had time to dig deeper into it. I'll leave that
to the pros :)

// Pontus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.