]> granicus.if.org Git - php/commitdiff
MFB: correct fix for bug #39662 to fix leak and tree corruption
authorRob Richards <rrichards@php.net>
Wed, 29 Nov 2006 08:52:08 +0000 (08:52 +0000)
committerRob Richards <rrichards@php.net>
Wed, 29 Nov 2006 08:52:08 +0000 (08:52 +0000)
fix test

ext/simplexml/simplexml.c
ext/simplexml/tests/bug39662.phpt

index a8129efd4e96be1c20333aaec56e2e176be5d7a5..9859814c60450207d214d412ac3ebe64018ff8d6 100644 (file)
@@ -1232,7 +1232,7 @@ SXE_METHOD(asXML)
                                }
                        }
 
-                       if (XML_DOCUMENT_NODE == node->parent->type) {
+                       if (node->parent && (XML_DOCUMENT_NODE == node->parent->type)) {
                                int bytes;
                                bytes = xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr);
                                if (bytes == -1) {
@@ -1265,7 +1265,7 @@ SXE_METHOD(asXML)
        node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
        if (node) {
-               if (XML_DOCUMENT_NODE == node->parent->type) {
+               if (node->parent && (XML_DOCUMENT_NODE == node->parent->type)) {
                        xmlDocDumpMemory((xmlDocPtr) sxe->document->ptr, &strval, &strval_len);
                        RETVAL_STRINGL((char *)strval, strval_len, 1);
                        xmlFree(strval);
@@ -1784,7 +1784,6 @@ sxe_object_clone(void *object, void **clone_ptr TSRMLS_DC)
        }
        if (sxe->node) {
                nodep = xmlDocCopyNode(sxe->node->node, docp, 1);
-               nodep->parent = sxe->node->node->parent;
        }
 
        php_libxml_increment_node_ptr((php_libxml_node_object *)clone, nodep, NULL TSRMLS_CC);
index c55df8b9055c7dcf65d77f147d58d9960b5e2407..b3ef25c89fb92c0b9a13d30a19f0ac727219404d 100644 (file)
@@ -31,11 +31,9 @@ object(SimpleXMLElement)#%d (1) {
 
 "
 }
-string(55) "<?xml version="1.0" encoding="utf-8"?>
-<test>
+string(15) "<test>
 
-</test>
-"
+</test>"
 Done
 --UEXPECTF--
 object(SimpleXMLElement)#%d (1) {
@@ -50,9 +48,7 @@ object(SimpleXMLElement)#%d (1) {
 
 "
 }
-string(55) "<?xml version="1.0" encoding="utf-8"?>
-<test>
+string(15) "<test>
 
-</test>
-"
+</test>"
 Done