In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/1141a2c757171575dd43caa4b731ca4f491c2bcf?hp=5956eec7c8ad0c228d38f744371ebafd305d8088>
- Log ----------------------------------------------------------------- commit 1141a2c757171575dd43caa4b731ca4f491c2bcf Author: Tony Cook <t...@develop-help.com> Date: Thu Aug 24 14:38:41 2017 +1000 (perl #131949) adjust s in case peekspace() moves the line string ----------------------------------------------------------------------- Summary of changes: t/comp/parser_run.t | 12 +++++++++++- toke.c | 5 ++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/t/comp/parser_run.t b/t/comp/parser_run.t index a2cc27d3fb..af35758bee 100644 --- a/t/comp/parser_run.t +++ b/t/comp/parser_run.t @@ -10,7 +10,7 @@ BEGIN { } require './test.pl'; -plan(3); +plan(4); # [perl #130814] can reallocate lineptr while looking ahead for # "Missing $ on loop variable" diagnostic. @@ -39,5 +39,15 @@ syntax error at - line 1, at EOF Execution of - aborted due to compilation errors. EXPECTED +SKIP: +{ + # [perl #131949] use after free + # detected by ASAN + # Win32 cmd.exe can't handle newlines well + skip("Need POSIXish", 1) if $^O eq "MSWin32"; + my $out = runperl(prog => "\@{ 0\n\n}", stderr => 1, non_portable => 1); + is($out, "", "check for ASAN use after free"); +} + __END__ # ex: set ts=8 sts=4 sw=4 et: diff --git a/toke.c b/toke.c index 35940be787..4f370895c0 100644 --- a/toke.c +++ b/toke.c @@ -9438,10 +9438,13 @@ S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni) if ( !tmp_copline ) tmp_copline = CopLINE(PL_curcop); - if ((skip = s < PL_bufend && isSPACE(*s))) + if ((skip = s < PL_bufend && isSPACE(*s))) { /* Avoid incrementing line numbers or resetting PL_linestart, in case we have to back up. */ + STRLEN s_off = s - SvPVX(PL_linestr); s2 = peekspace(s); + s = SvPVX(PL_linestr) + s_off; + } else s2 = s; -- Perl5 Master Repository