]> granicus.if.org Git - php/commitdiff
Avoid uncollectable cycle in sxe_property_get_adr
authorNikita Popov <nikic@php.net>
Sat, 16 Jul 2016 21:35:08 +0000 (23:35 +0200)
committerNikita Popov <nikic@php.net>
Sat, 16 Jul 2016 21:43:24 +0000 (23:43 +0200)
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.

ext/simplexml/simplexml.c

index 9e7e1145541055f8269cd77037f6841277265375..622ff3b6ec6cf038bc4ad0d2fd9986481480df9f 100644 (file)
@@ -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);
        }