com php-src: Fix bug #69832 (Assertion failure): Zend/tests/bug69832.phpt Zend/zend_compile.c
| From: | Bob Weinand | Date: | Mon, 15 Jun 2015 15:43:09 +0000 |
| Subject: | com php-src: Fix bug #69832 (Assertion failure): Zend/tests/bug69832.phpt Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87284@lists.php.net to get a copy of this message | ||
Commit: 9db81340bab6e30b4b67126b500a042d61682c9d
Author: Bob Weinand <bobwei9@hotmail.com> Mon, 15 Jun 2015 17:41:47 +0200
Parents: 556423fcd0214dd24afad5c008f7ad0075d48200
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9db81340bab6e30b4b67126b500a042d61682c9d
Log:
Fix bug #69832 (Assertion failure)
Bugs:
https://bugs.php.net/69832
Changed paths:
A Zend/tests/bug69832.phpt
M Zend/zend_compile.c
Diff:
diff --git a/Zend/tests/bug69832.phpt b/Zend/tests/bug69832.phpt
new file mode 100644
index 0000000..64f1634
--- /dev/null
+++ b/Zend/tests/bug69832.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #69832 (Assertion failed in zend_compile_const_expr_magic_const)
+--FILE--
+<?php
+
+class Test {
+ public $foo = [Bar::A, __CLASS__];
+}
+
+eval(<<<'PHP'
+class Bar {
+ const A = 1;
+}
+PHP
+);
+
+var_dump((new Test)->foo);
+
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ string(4) "Test"
+}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index bd7b65f..e934fef 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5621,6 +5621,7 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
{
zend_ast_list *list = zend_ast_get_list(ast);
uint32_t i;
+ zend_bool is_constant = 1;
/* First ensure that *all* child nodes are constant and by-val */
for (i = 0; i < list->children; ++i) {
@@ -5632,10 +5633,14 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{
*/
if (by_ref || elem_ast->child[0]->kind != ZEND_AST_ZVAL
|| (elem_ast->child[1] && elem_ast->child[1]->kind != ZEND_AST_ZVAL)
) {
- return 0;
+ is_constant = 0;
}
}
+ if (!is_constant) {
+ return 0;
+ }
+
array_init_size(result, list->children);
for (i = 0; i < list->children; ++i) {
zend_ast *elem_ast = list->child[i];