Skip to content
Open
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
5 changes: 3 additions & 2 deletions ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,8 +1224,9 @@ static HashTable *sxe_get_gc(zend_object *object, zval **table, int *n) /* {{{ *
php_sxe_object *sxe;
sxe = php_sxe_fetch_object(object);

*table = NULL;
*n = 0;
/* sxe->tmp is handed out by reference and can hold the element itself */
*table = &sxe->tmp;
*n = 1;
return sxe->properties;
}
/* }}} */
Expand Down
25 changes: 25 additions & 0 deletions ext/simplexml/tests/get_gc_tmp_cycle.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
SimpleXMLElement: a cycle through the by-reference property of a missing element is collected
--EXTENSIONS--
simplexml
--FILE--
<?php
$x = simplexml_load_string('<r/>');
$w = WeakReference::create($x);
$r = &$x->n;
$r = $x;
unset($r, $x);
gc_collect_cycles();
var_dump($w->get() === null);

function g(&$o, $v) { $o = $v; }
$x = simplexml_load_string('<r/>');
$w = WeakReference::create($x);
g($x->n, $x);
unset($x);
gc_collect_cycles();
var_dump($w->get() === null);
?>
--EXPECT--
bool(true)
bool(true)
Loading