rrichards               Tue Jul 31 15:40:00 2007 UTC

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
  Log:
  fix bug #41833 (addChild() on a non-existent node, no node created, getName() 
segfaults)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.242&r2=1.243&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.242 
php-src/ext/simplexml/simplexml.c:1.243
--- php-src/ext/simplexml/simplexml.c:1.242     Tue Jul 31 15:07:15 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Jul 31 15:39:59 2007
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.242 2007/07/31 15:07:15 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.243 2007/07/31 15:39:59 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1625,6 +1625,11 @@
 
        node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
+       if (node == NULL) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add child. 
Parent is not a permanent member of the XML tree");
+               return; 
+       }
+
        localname = xmlSplitQName2((xmlChar *)qname, &prefix);
        if (localname == NULL) {
                localname = xmlStrdup((xmlChar *)qname);
@@ -1637,9 +1642,7 @@
                        newnode->ns = NULL;
                        nsptr = xmlNewNs(newnode, (xmlChar *)nsuri, prefix);
                } else {
-                       if (node) {
-                               nsptr = xmlSearchNsByHref(node->doc, node, 
(xmlChar *)nsuri);
-                       }
+                       nsptr = xmlSearchNsByHref(node->doc, node, (xmlChar 
*)nsuri);
                        if (nsptr == NULL) {
                                nsptr = xmlNewNs(newnode, (xmlChar *)nsuri, 
prefix);
                        }
@@ -2500,7 +2503,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.242 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.243 $");
        php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");

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

Reply via email to