In perl.git, the branch blead has been updated <https://perl5.git.perl.org/perl.git/commitdiff/4efcdc0252c3ba1728081298180489b8772bc6d6?hp=d1ac83c4011b4bf51ca3fb070737a97a6c6ac545>
- Log ----------------------------------------------------------------- commit 4efcdc0252c3ba1728081298180489b8772bc6d6 Author: Lukas Mai <l....@web.de> Date: Sun Nov 12 02:58:32 2017 +0100 prevent invalid memory access in S_check_uni (RT #132433) ----------------------------------------------------------------------- Summary of changes: t/comp/parser_run.t | 8 +++++++- toke.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/t/comp/parser_run.t b/t/comp/parser_run.t index eba4b9fba8..2408fcd2b4 100644 --- a/t/comp/parser_run.t +++ b/t/comp/parser_run.t @@ -10,7 +10,7 @@ BEGIN { set_up_inc( qw(. ../lib ) ); } -plan(4); +plan(5); # [perl #130814] can reallocate lineptr while looking ahead for # "Missing $ on loop variable" diagnostic. @@ -49,5 +49,11 @@ SKIP: is($out, "", "check for ASAN use after free"); } +fresh_perl_is('-C-', <<'EXPECTED', {}, "ambiguous unary operator check doesn't crash (#132433)"); +Warning: Use of "-C-" without parentheses is ambiguous at - line 1. +syntax error at - line 1, at EOF +Execution of - aborted due to compilation errors. +EXPECTED + __END__ # ex: set ts=8 sts=4 sw=4 et: diff --git a/toke.c b/toke.c index c8ca63adbb..3dd4b47470 100644 --- a/toke.c +++ b/toke.c @@ -1935,7 +1935,7 @@ S_check_uni(pTHX) s = PL_last_uni; while (isWORDCHAR_lazy_if_safe(s, PL_bufend, UTF) || *s == '-') s += UTF ? UTF8SKIP(s) : 1; - if (memchr(s, '(', PL_bufptr - s)) + if (s < PL_bufptr && memchr(s, '(', PL_bufptr - s)) return; Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS), -- Perl5 Master Repository