]> granicus.if.org Git - php/commitdiff
- Fix some memleaks
authorMarcus Boerger <helly@php.net>
Tue, 29 Nov 2005 02:46:19 +0000 (02:46 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 29 Nov 2005 02:46:19 +0000 (02:46 +0000)
ext/simplexml/simplexml.c

index ed1b06ec3647bcf57aae9d15a1d84444d204b887..33f12c04509a97e3ad5059bd76f267b87dcbf483 100644 (file)
@@ -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;
                                }