Skip to content

Commit 239e2dd

Browse files
committed
Make sure T_ERROR is returned for all lexer exceptions
This originally manifested as a leak in oss-fuzz php#18000. The following is a reduced test case: <?php [ 5 => 1, "foo" > 1, " " => "" == 0 ]; <<<BAR $x BAR; Because this particular error condition did not return T_ERROR, EG(exception) was set while performing binary operation constant evaluation, which checks exceptions for cast failures. Instead of adding this indirect test case, I'm adding an assertion that the lexer has to return T_ERROR if EG(exception) is set.
1 parent 1d6e9da commit 239e2dd

File tree

3 files changed

+153
-119
lines changed

3 files changed

+153
-119
lines changed

Zend/zend_compile.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,13 +1693,17 @@ ZEND_API void zend_activate_auto_globals(void) /* {{{ */
16931693
int ZEND_FASTCALL zendlex(zend_parser_stack_elem *elem) /* {{{ */
16941694
{
16951695
zval zv;
1696+
int ret;
16961697

16971698
if (CG(increment_lineno)) {
16981699
CG(zend_lineno)++;
16991700
CG(increment_lineno) = 0;
17001701
}
17011702

1702-
return lex_scan(&zv, elem);
1703+
ret = lex_scan(&zv, elem);
1704+
ZEND_ASSERT(!EG(exception) || ret == T_ERROR);
1705+
return ret;
1706+
17031707
}
17041708
/* }}} */
17051709

0 commit comments

Comments
 (0)