From: Nikita Popov Date: Sat, 16 Jul 2016 21:35:08 +0000 (+0200) Subject: Avoid uncollectable cycle in sxe_property_get_adr X-Git-Tag: php-7.1.0beta1~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=735bec4f4018a4009a37d96489afe941c1ad711a;p=php Avoid uncollectable cycle in sxe_property_get_adr The code was storing the created object in a property on the created object, creating a trivial cycle. This cycle cannot be collected (even if sxe->tmp is exposed via get_gc), because it is never rooted (and we cannot safely manually root it). Change the code to store the created object on the parent node instead. The only reason this is not showing up as a leak is that sxe->tmp is dtor'ed in the dtor handler, which means that these objects do get collected on shutdown -- but never earlier. --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 9e7e114554..622ff3b6ec 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -713,7 +713,6 @@ static zval *sxe_property_get_adr(zval *object, zval *member, int fetch_type, vo _node_as_zval(sxe, node, &ret, type, name, sxe->iter.nsprefix, sxe->iter.isprefix); - sxe = Z_SXEOBJ_P(&ret); if (!Z_ISUNDEF(sxe->tmp)) { zval_ptr_dtor(&sxe->tmp); }