mirror of
https://github.com/php/php-src.git
synced 2024-11-28 12:26:37 +08:00
MFH: fix bug #41833 (addChild() on a non-existent node, no node created, getName() segfaults)
This commit is contained in:
parent
ce582024a5
commit
e0a2d149f5
@ -1563,6 +1563,11 @@ SXE_METHOD(addChild)
|
||||
|
||||
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 @@ SXE_METHOD(addChild)
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user