Fix parser buffer corruption with multiline *{...}
authorFather Chrysostomos <sprout@cpan.org>
Fri, 20 Sep 2013 07:33:49 +0000 (00:33 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 20 Sep 2013 08:19:07 +0000 (01:19 -0700)
commit4aaee9b8df62149cfed9099d3b9422c6d397c274
treef698b358a7ca2fa5002f1b18c2499f90b5a90d5e
parent364b4e90ddaca97dd7233f3266dbaa36aabbe6f5
Fix parser buffer corruption with multiline *{...}

Since commit a49b10d0a, it has been possible for scan_ident in toke.c
to reallocate the parser’s buffer (SvPVX(PL_linestr)) when scanning
for multiline whitespace.

For the sake of those cases where it finds an arbitrary expression,
not just an identifier, it records a pointer to the first opening
brace, which it returns to the parser after finding out that there is
indeed an expression.

That pointer was not being updated when the buffer was being
allocated.

The solution is to record an offset, rather than a pointer, of the
opening brace relative to the beginning of the current line of input.

This one-liner:

$ ./miniperl  -e '*{' -e '         XS::APItest::gv_fetchmeth_type()' -e '}'

was giving me:

Unrecognized character \x80; marked by <-- HERE after 2<-- HERE near column 24 at -e line 2.

(There were nine nulls before the 2, but git stripped them out.)
t/op/lex.t
toke.c