diff --git a/NEWS b/NEWS index e4f488e8ace..a578fdbf482 100644 --- a/NEWS +++ b/NEWS @@ -62,6 +62,8 @@ PHP NEWS (Tobias Bachert) . Added error_log_mode ini setting. (Mikhail Galanin) . Updated request startup messages. (Eric Norris) + . Fixed GH-9136 and GH-9138 (Fixed fetching property of magic constant in + constant expressions). (ilutov) - COM: . Fixed bug GH-8750 (Can not create VT_ERROR variant type). (cmb) diff --git a/Zend/tests/gh9136.phpt b/Zend/tests/gh9136.phpt new file mode 100644 index 00000000000..22c4a056520 --- /dev/null +++ b/Zend/tests/gh9136.phpt @@ -0,0 +1,10 @@ +--TEST-- +GH-9136: Assertion when fetching property of magic constant in constant expression +--FILE-- +foo; + +?> +--EXPECTF-- +Warning: Attempt to read property "foo" on string in %s on line %d diff --git a/Zend/tests/gh9138.phpt b/Zend/tests/gh9138.phpt new file mode 100644 index 00000000000..33550580527 --- /dev/null +++ b/Zend/tests/gh9138.phpt @@ -0,0 +1,11 @@ +--TEST-- +GH-9138: NULL pointer dereference when fetching property of "bad" list in constant expression +--FILE-- +e)] +class Foo {} + +?> +--EXPECTF-- +Fatal error: Cannot use empty array elements in arrays in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 7dd3d598df1..ff7c9b152cd 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -10616,6 +10616,10 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ case ZEND_AST_CONST_ENUM_INIT: zend_eval_const_expr(&ast->child[2]); return; + case ZEND_AST_PROP: + zend_eval_const_expr(&ast->child[0]); + zend_eval_const_expr(&ast->child[1]); + return; default: return; }