From f799b0b19b1b1f25ba6ce5ec2e66346ba8d659fe Mon Sep 17 00:00:00 2001 From: Rob Richards Date: Wed, 29 Nov 2006 08:52:08 +0000 Subject: [PATCH] MFB: correct fix for bug #39662 to fix leak and tree corruption fix test --- ext/simplexml/simplexml.c | 5 ++--- ext/simplexml/tests/bug39662.phpt | 12 ++++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index a8129efd4e..9859814c60 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -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); diff --git a/ext/simplexml/tests/bug39662.phpt b/ext/simplexml/tests/bug39662.phpt index c55df8b905..b3ef25c89f 100644 --- a/ext/simplexml/tests/bug39662.phpt +++ b/ext/simplexml/tests/bug39662.phpt @@ -31,11 +31,9 @@ object(SimpleXMLElement)#%d (1) { " } -string(55) " - +string(15) " - -" +" Done --UEXPECTF-- object(SimpleXMLElement)#%d (1) { @@ -50,9 +48,7 @@ object(SimpleXMLElement)#%d (1) { " } -string(55) " - +string(15) " - -" +" Done -- 2.50.1