rrichards               Wed Nov 29 08:52:09 2006 UTC

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
    /php-src/ext/simplexml/tests        bug39662.phpt 
  Log:
  MFB: correct fix for bug #39662 to fix leak and tree corruption
  fix test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.222&r2=1.223&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.222 
php-src/ext/simplexml/simplexml.c:1.223
--- php-src/ext/simplexml/simplexml.c:1.222     Tue Nov 28 18:57:37 2006
+++ php-src/ext/simplexml/simplexml.c   Wed Nov 29 08:52:08 2006
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.222 2006/11/28 18:57:37 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.223 2006/11/29 08:52:08 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1232,7 +1232,7 @@
                                }
                        }
 
-                       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 @@
        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 @@
        }
        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);
@@ -2362,7 +2361,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.222 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.223 $");
        php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug39662.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/simplexml/tests/bug39662.phpt
diff -u php-src/ext/simplexml/tests/bug39662.phpt:1.1 
php-src/ext/simplexml/tests/bug39662.phpt:1.2
--- php-src/ext/simplexml/tests/bug39662.phpt:1.1       Tue Nov 28 18:57:37 2006
+++ php-src/ext/simplexml/tests/bug39662.phpt   Wed Nov 29 08:52:08 2006
@@ -31,11 +31,9 @@
 
 "
 }
-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 @@
 
 "
 }
-string(55) "<?xml version="1.0" encoding="utf-8"?>
-<test>
+string(15) "<test>
 
-</test>
-"
+</test>"
 Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to