From: Rob Richards Date: Sat, 28 Jun 2003 21:38:44 +0000 (+0000) Subject: fix mem leak in sxe_property_read X-Git-Tag: php-5.0.0b1~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a2259344502e8244ac5bbd4b46421d416ac82542;p=php fix mem leak in sxe_property_read fix compiler warning --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 10f24f7aa0..35fc724c21 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -26,6 +26,7 @@ #include "php_ini.h" #include "ext/standard/info.h" #include "php_simplexml.h" +#include "zend_execute_locks.h" zend_class_entry *sxe_class_entry; @@ -105,8 +106,7 @@ sxe_property_read(zval *object, zval *member TSRMLS_DC) xmlAttrPtr attr; int counter = 0; - ALLOC_ZVAL(return_value); - return_value->refcount = 0; + MAKE_STD_ZVAL(return_value); ZVAL_NULL(return_value); name = Z_STRVAL_P(member); @@ -146,7 +146,6 @@ sxe_property_read(zval *object, zval *member TSRMLS_DC) if (match_ns(sxe, node, name)) { MAKE_STD_ZVAL(value); _node_as_zval(sxe, node->parent, value TSRMLS_CC); - value->refcount = 0; APPEND_CUR_ELEMENT(counter, value); goto next_iter; } @@ -156,8 +155,6 @@ sxe_property_read(zval *object, zval *member TSRMLS_DC) APPEND_PREV_ELEMENT(counter, value); MAKE_STD_ZVAL(value); _node_as_zval(sxe, node, value TSRMLS_CC); - value->refcount = 0; - APPEND_CUR_ELEMENT(counter, value); } @@ -173,6 +170,9 @@ next_iter: return_value = value; } + /* create temporary variable */ + PZVAL_UNLOCK(return_value); + return return_value; } /* }}} */ @@ -207,7 +207,7 @@ sxe_property_write(zval *object, zval *member, zval *value TSRMLS_DC) php_sxe_object *sxe; char *name; xmlNodePtr node; - xmlNodePtr newnode; + xmlNodePtr newnode = NULL; xmlAttrPtr attr; int counter = 0; int is_attr = 0;