Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ PHP NEWS
- Standard:
. Passing strings which are not one byte long to ord() is now deprecated.
(Girgias)
. Fixed bug GH-19801 (leaks in var_dump() and debug_zval_dump()).
(alexandre-daubois)

- URI:
. Fixed bug GH-19780 (InvalidUrlException should check $errors argument).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
GH-19801 (debug_zval_dump() leak with __debugInfo() that modifies circular references)
--FILE--
<?php

$a = [
new class {
function __debugInfo() {
global $b;
$b->a = null;
gc_collect_cycles();
return [];
}
},
];

$b = new stdClass;
$b->a = &$a;

debug_zval_dump($b);
?>
--EXPECTF--
object(stdClass)#2 (1) refcount(%d){
["a"]=>
reference refcount(%d) {
array(1) packed refcount(%d){
[0]=>
object(class@anonymous)#1 (0) refcount(%d){
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
GH-19801 (var_dump() memory leak with __debugInfo() that modifies circular references)
--FILE--
<?php

$a = [
new class {
function __debugInfo() {
global $b;
$b->a = null;
gc_collect_cycles();
return [];
}
},
];

$b = new stdClass;
$b->a = &$a;

var_dump($b);
?>
--EXPECTF--
object(stdClass)#2 (1) {
["a"]=>
&array(1) {
[0]=>
object(class@anonymous)#1 (0) {
}
}
}
4 changes: 2 additions & 2 deletions ext/standard/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
} ZEND_HASH_FOREACH_END();
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(myht);
GC_DELREF(myht);
GC_DTOR_NO_REF(myht);
}
if (level > 1) {
php_printf("%*c", level-1, ' ');
Expand Down Expand Up @@ -354,7 +354,7 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
} ZEND_HASH_FOREACH_END();
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(myht);
GC_DELREF(myht);
GC_DTOR_NO_REF(myht);
}
if (level > 1) {
php_printf("%*c", level - 1, ' ');
Expand Down