summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-07-07 10:11:34 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-07-07 10:19:39 +0200
commitb765f96f5f6d7d5da77e1d57f80b98f1fde16cde (patch)
treee925dc30cc86737870a1bc7bea22635126b34672
parent187a72d563914a0f9a0f97d26956aff4fb5c3fe6 (diff)
downloadphp-git-b765f96f5f6d7d5da77e1d57f80b98f1fde16cde.tar.gz
Fixed bug #79778
In the interest of avoiding side-effects during dumping, I'm replacing the value with a <constant ast> string instead of performing an update constant operation.
-rw-r--r--NEWS4
-rw-r--r--Zend/tests/bug79778.phpt26
-rw-r--r--Zend/zend_closures.c7
3 files changed, 37 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 57b3899215..279ce98c61 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #79030 (Upgrade apache2handler's php_apache_sapi_get_request_time
to return usec). (Herbert256)
+- Core:
+ . Fixed bug #79778 (Assertion failure if dumping closure with unresolved
+ static variable). (Nikita)
+
- COM:
. Fixed bug #63208 (BSTR to PHP string conversion not binary safe). (cmb)
diff --git a/Zend/tests/bug79778.phpt b/Zend/tests/bug79778.phpt
new file mode 100644
index 0000000000..f1476a95cf
--- /dev/null
+++ b/Zend/tests/bug79778.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #79778: Assertion failure if dumping closure with unresolved static variable
+--FILE--
+<?php
+$closure1 = function() {
+ static $var = CONST_REF;
+};
+var_dump($closure1);
+print_r($closure1);
+?>
+--EXPECT--
+object(Closure)#1 (1) {
+ ["static"]=>
+ array(1) {
+ ["var"]=>
+ string(14) "<constant ast>"
+ }
+}
+Closure Object
+(
+ [static] => Array
+ (
+ [var] => <constant ast>
+ )
+
+)
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index 4261a74860..b9d8bd1c75 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -506,9 +506,16 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
debug_info = zend_new_array(8);
if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) {
+ zval *var;
HashTable *static_variables = closure->func.op_array.static_variables;
ZVAL_ARR(&val, zend_array_dup(static_variables));
zend_hash_update(debug_info, ZSTR_KNOWN(ZEND_STR_STATIC), &val);
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL(val), var) {
+ if (Z_TYPE_P(var) == IS_CONSTANT_AST) {
+ zval_ptr_dtor(var);
+ ZVAL_STRING(var, "<constant ast>");
+ }
+ } ZEND_HASH_FOREACH_END();
}
if (Z_TYPE(closure->this_ptr) != IS_UNDEF) {