diff --git a/NEWS b/NEWS index acb77999a52..5ea88655fa4 100644 --- a/NEWS +++ b/NEWS @@ -12,7 +12,9 @@ PHP NEWS - Core: . Fixed bug #79740 (serialize() and unserialize() methods can not be called statically). (Nikita) - . Fixede bug #79783 (Segfault in php_str_replace_common). (Nikita) + . Fixed bug #79783 (Segfault in php_str_replace_common). (Nikita) + . Fixed bug #79778 (Assertion failure if dumping closure with unresolved + static variable). (Nikita) - Fileinfo: . Fixed bug #79756 (finfo_file crash (FILEINFO_MIME)). (cmb) diff --git a/Zend/tests/bug79778.phpt b/Zend/tests/bug79778.phpt new file mode 100644 index 00000000000..f1476a95cf8 --- /dev/null +++ b/Zend/tests/bug79778.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #79778: Assertion failure if dumping closure with unresolved static variable +--FILE-- + +--EXPECT-- +object(Closure)#1 (1) { + ["static"]=> + array(1) { + ["var"]=> + string(14) "" + } +} +Closure Object +( + [static] => Array + ( + [var] => + ) + +) diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 92f1398d840..70dc469a481 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -531,10 +531,17 @@ 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 = ZEND_MAP_PTR_GET(closure->func.op_array.static_variables_ptr); 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, ""); + } + } ZEND_HASH_FOREACH_END(); } if (Z_TYPE(closure->this_ptr) != IS_UNDEF) {