summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-10-02 12:07:19 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-10-02 12:07:19 +0200
commit3c42471ef84dcd6008ee54c0dc6cecb47b5da86b (patch)
tree5e42580d5be7bdf76a2ec5c6b7716947117bfc02 /Zend
parentf7596d1b5bd263ee7e0371d125bee37a675c0c7e (diff)
parenta5d3620d937f69665d78ab8d21c757d3db17b5ec (diff)
downloadphp-git-3c42471ef84dcd6008ee54c0dc6cecb47b5da86b.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/halt_compiler5.phpt8
-rw-r--r--Zend/zend_compile.c3
2 files changed, 11 insertions, 0 deletions
diff --git a/Zend/tests/halt_compiler5.phpt b/Zend/tests/halt_compiler5.phpt
new file mode 100644
index 0000000000..71d973e4f7
--- /dev/null
+++ b/Zend/tests/halt_compiler5.phpt
@@ -0,0 +1,8 @@
+--TEST--
+Using __COMPILER_HALF_OFFSET__ with trailing {} (OSS-Fuzz #17895)
+--FILE--
+<?php
+__COMPILER_HALT_OFFSET__;
+{}
+--EXPECTF--
+Warning: Use of undefined constant __COMPILER_HALT_OFFSET__ - assumed '__COMPILER_HALT_OFFSET__' (this will throw an Error in a future version of PHP) in %s on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 0c576a86ca..fbf65822d4 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -7764,6 +7764,9 @@ void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */
while (last && last->kind == ZEND_AST_STMT_LIST) {
zend_ast_list *list = zend_ast_get_list(last);
+ if (list->children == 0) {
+ break;
+ }
last = list->child[list->children-1];
}
if (last && last->kind == ZEND_AST_HALT_COMPILER) {