From 73d6456d7d6be62340b3607805a45cbf420c1cb8 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 24 Sep 2017 08:53:27 +0200 Subject: Fixed bug #75252 --- NEWS | 2 ++ Zend/tests/bug75252.phpt | 28 ++++++++++++++++++++++++++++ Zend/zend.c | 2 ++ main/main.c | 4 +--- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 Zend/tests/bug75252.phpt diff --git a/NEWS b/NEWS index f937e78d7d..f1cc520650 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ PHP NEWS - Core: . Fixed bug #75236 (infinite loop when printing an error-message). (Andrea) + . Fixed bug #75252 (Incorrect token formatting on two parse errors in one + request). (Nikita) - SPL: . Fixed bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags). diff --git a/Zend/tests/bug75252.phpt b/Zend/tests/bug75252.phpt new file mode 100644 index 0000000000..16679e4d6e --- /dev/null +++ b/Zend/tests/bug75252.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #75252: Incorrect token formatting on two parse errors in one request +--FILE-- +getMessage()); +} + +try { + eval($code); +} catch (ParseError $e) { + var_dump($e->getMessage()); +} + +?> +--EXPECT-- +string(41) "syntax error, unexpected 'FOO' (T_STRING)" +string(41) "syntax error, unexpected 'FOO' (T_STRING)" diff --git a/Zend/zend.c b/Zend/zend.c index 110673e795..bca1dbd9df 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -896,6 +896,8 @@ void zend_set_utility_values(zend_utility_values *utility_values) /* {{{ */ /* this should be compatible with the standard zenderror */ ZEND_COLD void zenderror(const char *error) /* {{{ */ { + CG(parse_error) = 0; + if (EG(exception)) { /* An exception was thrown in the lexer, don't throw another in the parser. */ return; diff --git a/main/main.c b/main/main.c index 48c1a63c72..ce33cfb983 100644 --- a/main/main.c +++ b/main/main.c @@ -1200,9 +1200,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u sapi_header_op(SAPI_HEADER_REPLACE, &ctr); } /* the parser would return 1 (failure), we can bail out nicely */ - if (type == E_PARSE) { - CG(parse_error) = 0; - } else { + if (type != E_PARSE) { /* restore memory limit */ zend_set_memory_limit(PG(memory_limit)); efree(buffer); -- cgit v1.2.1