rrichards Tue Jul 31 15:40:49 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/simplexml simplexml.c
Log:
MFH: 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.151.2.22.2.34&r2=1.151.2.22.2.35&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.22.2.34
php-src/ext/simplexml/simplexml.c:1.151.2.22.2.35
--- php-src/ext/simplexml/simplexml.c:1.151.2.22.2.34 Tue Jul 31 15:07:54 2007
+++ php-src/ext/simplexml/simplexml.c Tue Jul 31 15:40:49 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: simplexml.c,v 1.151.2.22.2.34 2007/07/31 15:07:54 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.151.2.22.2.35 2007/07/31 15:40:49 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1563,6 +1563,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);
@@ -1575,9 +1580,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);
}
@@ -2437,7 +2440,7 @@
{
php_info_print_table_start();
php_info_print_table_header(2, "Simplexml support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.34 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.35 $");
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