summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-08-26 18:26:14 +0200
committerYves Orton <demerphq@gmail.com>2022-09-09 18:48:52 +0200
commiteb54d46f7264ff7af62c409d8a6ab984a5a34f57 (patch)
tree87c90a0747b065f8994c54d569cb1b50eb7ae09b /perl.c
parent14580ae6b927552985b6b6294f9e836df39d0b65 (diff)
downloadperl-eb54d46f7264ff7af62c409d8a6ab984a5a34f57.tar.gz
Stop parsing on first syntax error.
We try to keep parsing after many types of errors, up to a (current) maximum of 10 errors. Continuing after a semantic error (like undeclared variables) can be helpful, for instance showing a set of common errors, but continuing after a syntax error isn't helpful most of the time as the internal state of the parser can get confused and is not reliably restored in between attempts. This can produce sometimes completely bizarre errors which just obscure the true error, and has resulted in security tickets being filed in the past. This patch makes the parser stop after the first syntax error, while preserving the current behavior for other errors. An error is considered a syntax error if the error message from our internals is the literal text "syntax error". This may not be a complete list of true syntax errors, we can iterate on that in the future. This fixes the segfaults reported in Issue #17397, and #16944 and likely fixes other "segfault due to compiler continuation after syntax error" bugs that we have on record, which has been a recurring issue over the years.
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/perl.c b/perl.c
index 1cfea3f997..343c117f44 100644
--- a/perl.c
+++ b/perl.c
@@ -2596,7 +2596,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
SETERRNO(0,SS_NORMAL);
if (yyparse(GRAMPROG) || PL_parser->error_count) {
- abort_execution("", PL_origfilename);
+ abort_execution(NULL, PL_origfilename);
}
CopLINE_set(PL_curcop, 0);
SET_CURSTASH(PL_defstash);