Skip to content

Commit b765f96

Browse files
committed
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.
1 parent 187a72d commit b765f96

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #79030 (Upgrade apache2handler's php_apache_sapi_get_request_time
77
to return usec). (Herbert256)
88

9+
- Core:
10+
. Fixed bug #79778 (Assertion failure if dumping closure with unresolved
11+
static variable). (Nikita)
12+
913
- COM:
1014
. Fixed bug #63208 (BSTR to PHP string conversion not binary safe). (cmb)
1115

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
@@ -506,9 +506,16 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
506506
debug_info = zend_new_array(8);
507507

508508
if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) {
509+
zval *var;
509510
HashTable *static_variables = closure->func.op_array.static_variables;
510511
ZVAL_ARR(&val, zend_array_dup(static_variables));
511512
zend_hash_update(debug_info, ZSTR_KNOWN(ZEND_STR_STATIC), &val);
513+
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(val), var) {
514+
if (Z_TYPE_P(var) == IS_CONSTANT_AST) {
515+
zval_ptr_dtor(var);
516+
ZVAL_STRING(var, "<constant ast>");
517+
}
518+
} ZEND_HASH_FOREACH_END();
512519
}
513520

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

0 commit comments

Comments
 (0)