Skip to content

Commit

Permalink
Fixed bug #75252
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Sep 24, 2017
1 parent da2f581 commit 73d6456
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
28 changes: 28 additions & 0 deletions Zend/tests/bug75252.phpt
Original file line number Diff line number Diff line change
@@ -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)"
2 changes: 2 additions & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 73d6456

Please sign in to comment.