diff options
| author | Rob Richards <rrichards@php.net> | 2006-11-29 08:51:36 +0000 |
|---|---|---|
| committer | Rob Richards <rrichards@php.net> | 2006-11-29 08:51:36 +0000 |
| commit | d5d1801df7d9dcd1a3aeb886da83189dbe20437d (patch) | |
| tree | 4c37afc17486e9762f92e207245a868a24eaef87 | |
| parent | ecd417c6ce6f164d06f1296a0beb2c8b7d6e7312 (diff) | |
| download | php-git-d5d1801df7d9dcd1a3aeb886da83189dbe20437d.tar.gz | |
correct fix for bug #39662 to fix leak and tree corruption
fix test
| -rw-r--r-- | ext/simplexml/simplexml.c | 5 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug39662.phpt | 6 |
2 files changed, 4 insertions, 7 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 43c6065fb5..d05b49505a 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1211,7 +1211,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)) { int bytes; bytes = xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr); if (bytes == -1) { @@ -1240,7 +1240,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); @@ -1762,7 +1762,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 47a0c27068..ae15f2ef0a 100644 --- a/ext/simplexml/tests/bug39662.phpt +++ b/ext/simplexml/tests/bug39662.phpt @@ -31,9 +31,7 @@ object(SimpleXMLElement)#%d (1) { " } -string(55) "<?xml version="1.0" encoding="utf-8"?> -<test> +string(15) "<test> -</test> -" +</test>" Done |
