Skip to content

Commit d9b4974

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #79778
2 parents 971e5c5 + b765f96 commit d9b4974

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

NEWS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ PHP NEWS
1212
- Core:
1313
. Fixed bug #79740 (serialize() and unserialize() methods can not be called
1414
statically). (Nikita)
15-
. Fixede bug #79783 (Segfault in php_str_replace_common). (Nikita)
15+
. Fixed bug #79783 (Segfault in php_str_replace_common). (Nikita)
16+
. Fixed bug #79778 (Assertion failure if dumping closure with unresolved
17+
static variable). (Nikita)
1618

1719
- Fileinfo:
1820
. Fixed bug #79756 (finfo_file crash (FILEINFO_MIME)). (cmb)

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
@@ -531,10 +531,17 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
531531
debug_info = zend_new_array(8);
532532

533533
if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) {
534+
zval *var;
534535
HashTable *static_variables =
535536
ZEND_MAP_PTR_GET(closure->func.op_array.static_variables_ptr);
536537
ZVAL_ARR(&val, zend_array_dup(static_variables));
537538
zend_hash_update(debug_info, ZSTR_KNOWN(ZEND_STR_STATIC), &val);
539+
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(val), var) {
540+
if (Z_TYPE_P(var) == IS_CONSTANT_AST) {
541+
zval_ptr_dtor(var);
542+
ZVAL_STRING(var, "<constant ast>");
543+
}
544+
} ZEND_HASH_FOREACH_END();
538545
}
539546

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

0 commit comments

Comments
 (0)