Skip to content

Commit 73d6456

Browse files
committed
Fixed bug #75252
1 parent da2f581 commit 73d6456

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PHP NEWS
44

55
- Core:
66
. Fixed bug #75236 (infinite loop when printing an error-message). (Andrea)
7+
. Fixed bug #75252 (Incorrect token formatting on two parse errors in one
8+
request). (Nikita)
79

810
- SPL:
911
. Fixed bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags).

Zend/tests/bug75252.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #75252: Incorrect token formatting on two parse errors in one request
3+
--FILE--
4+
<?php
5+
6+
$code = <<<'CODE'
7+
function test_missing_semicolon() : string {
8+
$x = []
9+
FOO
10+
}
11+
CODE;
12+
13+
try {
14+
eval($code);
15+
} catch (ParseError $e) {
16+
var_dump($e->getMessage());
17+
}
18+
19+
try {
20+
eval($code);
21+
} catch (ParseError $e) {
22+
var_dump($e->getMessage());
23+
}
24+
25+
?>
26+
--EXPECT--
27+
string(41) "syntax error, unexpected 'FOO' (T_STRING)"
28+
string(41) "syntax error, unexpected 'FOO' (T_STRING)"

Zend/zend.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,8 @@ void zend_set_utility_values(zend_utility_values *utility_values) /* {{{ */
896896
/* this should be compatible with the standard zenderror */
897897
ZEND_COLD void zenderror(const char *error) /* {{{ */
898898
{
899+
CG(parse_error) = 0;
900+
899901
if (EG(exception)) {
900902
/* An exception was thrown in the lexer, don't throw another in the parser. */
901903
return;

main/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,9 +1200,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
12001200
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
12011201
}
12021202
/* the parser would return 1 (failure), we can bail out nicely */
1203-
if (type == E_PARSE) {
1204-
CG(parse_error) = 0;
1205-
} else {
1203+
if (type != E_PARSE) {
12061204
/* restore memory limit */
12071205
zend_set_memory_limit(PG(memory_limit));
12081206
efree(buffer);

0 commit comments

Comments
 (0)