Skip to content

Commit 7da8c48

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79778
2 parents 1e39469 + d9b4974 commit 7da8c48

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Zend/tests/bug79778.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #79778: Assertion failure if dumping closure with unresolved static variable
3+
--FILE--
4+
<?php
5+
$closure1 = function() {
6+
static $var = CONST_REF;
7+
};
8+
var_dump($closure1);
9+
print_r($closure1);
10+
?>
11+
--EXPECT--
12+
object(Closure)#1 (1) {
13+
["static"]=>
14+
array(1) {
15+
["var"]=>
16+
string(14) "<constant ast>"
17+
}
18+
}
19+
Closure Object
20+
(
21+
[static] => Array
22+
(
23+
[var] => <constant ast>
24+
)
25+
26+
)

Zend/zend_closures.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,17 @@ static HashTable *zend_closure_get_debug_info(zend_object *object, int *is_temp)
524524
debug_info = zend_new_array(8);
525525

526526
if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) {
527+
zval *var;
527528
HashTable *static_variables =
528529
ZEND_MAP_PTR_GET(closure->func.op_array.static_variables_ptr);
529530
ZVAL_ARR(&val, zend_array_dup(static_variables));
530531
zend_hash_update(debug_info, ZSTR_KNOWN(ZEND_STR_STATIC), &val);
532+
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(val), var) {
533+
if (Z_TYPE_P(var) == IS_CONSTANT_AST) {
534+
zval_ptr_dtor(var);
535+
ZVAL_STRING(var, "<constant ast>");
536+
}
537+
} ZEND_HASH_FOREACH_END();
531538
}
532539

533540
if (Z_TYPE(closure->this_ptr) != IS_UNDEF) {

0 commit comments

Comments
 (0)