In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/d674449463a15ac3f36086e3a0bb3a9d02729887?hp=7832ad859a7fe7ff3d13488cd9bd5fc210c12ccd>
- Log ----------------------------------------------------------------- commit d674449463a15ac3f36086e3a0bb3a9d02729887 Author: Father Chrysostomos <[email protected]> Date: Tue May 17 18:16:52 2016 -0700 [perl #128171] Fix assert fail with /@0{0*->@*/*0 If a syntax error such as * (multiply) followed by an arrow causes the parser to pop scopes in trying to recover from the error, it might exit the quote-parsing scope (for parsing the regexp) and point the lexerâs cursor at the code following the regexp, after the lexer has noted to itself that it is expected to parse a postfix dereference (PL_expect==XPOSTDEREF). The code for parsing a postfix dereference has an assertion which ends up failing in this case, because the *0 following the regexp, having sigil that can come after an arrow, goes through the postfix deref function, which complains about the 0 it did not expect. If we simply remove the assertion, the lexer will continue to emit tokens, and we just end up dying (somewhat) gracefully because of the syntax error, instead of crashing. I used a ] in the test instead of a final 0, to avoid a compile- time warning. (Number found where operator expected.) ----------------------------------------------------------------------- Summary of changes: t/base/lex.t | 8 +++++++- toke.c | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/t/base/lex.t b/t/base/lex.t index 1aa563d..fe46f14 100644 --- a/t/base/lex.t +++ b/t/base/lex.t @@ -1,6 +1,6 @@ #!./perl -print "1..104\n"; +print "1..105\n"; $x = 'x'; @@ -522,3 +522,9 @@ eval q|s##[}#e|; eval ('qq{@{[0}*sub{]]}}}=sub{0' . "\c["); print "ok $test - 125350\n"; $test++; } + +{ + # Used to crash [perl #128171] + eval ('/@0{0*->@*/*]'); + print "ok $test - 128171\n"; $test++; +} diff --git a/toke.c b/toke.c index dcde140..4a20e61 100644 --- a/toke.c +++ b/toke.c @@ -1932,7 +1932,6 @@ static int S_postderef(pTHX_ int const funny, char const next) { assert(funny == DOLSHARP || strchr("$@%&*", funny)); - assert(strchr("*[{", next)); if (next == '*') { PL_expect = XOPERATOR; if (PL_lex_state == LEX_INTERPNORMAL && !PL_lex_brackets) { -- Perl5 Master Repository
