summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2017-09-24 08:53:27 +0200
committerNikita Popov <nikita.ppv@gmail.com>2017-09-24 08:53:27 +0200
commit73d6456d7d6be62340b3607805a45cbf420c1cb8 (patch)
tree7e2685a7487a529086d105179d9004d8889747e0
parentda2f58183377571fc7f10e5bdae1786f46fb9639 (diff)
downloadphp-git-73d6456d7d6be62340b3607805a45cbf420c1cb8.tar.gz
Fixed bug #75252
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug75252.phpt28
-rw-r--r--Zend/zend.c2
-rw-r--r--main/main.c4
4 files changed, 33 insertions, 3 deletions
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--
+<?php
+
+$code = <<<'CODE'
+function test_missing_semicolon() : string {
+ $x = []
+ FOO
+}
+CODE;
+
+try {
+ eval($code);
+} catch (ParseError $e) {
+ var_dump($e->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);