From: Marcus Boerger Date: Tue, 29 Nov 2005 02:46:19 +0000 (+0000) Subject: - Fix some memleaks X-Git-Tag: RELEASE_2_0_2~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d237f996f90f7a10791cd3d5bbb91de0fb5649f5;p=php - Fix some memleaks --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index ed1b06ec36..33f12c0450 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -746,10 +746,19 @@ static void sxe_dimension_delete(zval *object, zval *offset TSRMLS_DC) } /* }}} */ +static inline char * sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) +{ + xmlChar *tmp = xmlNodeListGetString(doc, list, inLine); + char *res = estrdup((char*)tmp); + + xmlFree(tmp); + + return res; +} + /* {{{ _get_base_node_value() */ -static void -_get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value, char *prefix TSRMLS_DC) +static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value, char *prefix TSRMLS_DC) { php_sxe_object *subnode; xmlChar *contents; @@ -838,7 +847,7 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC) while (attr) { if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && match_ns(sxe, (xmlNodePtr)attr, sxe->iter.nsprefix)) { MAKE_STD_ZVAL(value); - ZVAL_STRING(value, xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 1); + ZVAL_STRING(value, sxe_xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 0); namelen = xmlStrlen(attr->name) + 1; if (!zattr) { MAKE_STD_ZVAL(zattr); @@ -856,7 +865,7 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC) if (node && sxe->iter.type != SXE_ITER_ATTRLIST) { if (node->type == XML_ATTRIBUTE_NODE) { MAKE_STD_ZVAL(value); - ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, xmlNodeListGetString(node->doc, node->children, 1), 1); + ZVAL_STRING(value, sxe_xmlNodeListGetString(node->doc, node->children, 1), 0); zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); node = NULL; } else { @@ -869,7 +878,7 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC) } else { if (node->type == XML_TEXT_NODE) { MAKE_STD_ZVAL(value); - ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, xmlNodeListGetString(node->doc, node, 1), 1); + ZVAL_STRING(value, sxe_xmlNodeListGetString(node->doc, node, 1), 0); zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); goto next_iter; }