summaryrefslogtreecommitdiff
path: root/ext/dom
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2005-04-18 23:07:50 +0000
committerRob Richards <rrichards@php.net>2005-04-18 23:07:50 +0000
commit334d756ffa8ff67d11f3353559cb58ed4df96e1c (patch)
tree6a4373e757ecfeb8fe1d342bed1425f4d0920adc /ext/dom
parent4033ad1dd2d95c13a3b2b47ee8b6b5093bbfe631 (diff)
downloadphp-git-334d756ffa8ff67d11f3353559cb58ed4df96e1c.tar.gz
Fix bug #32755 Segfault in replaceChild() when DocumentFragment has no children
update test
Diffstat (limited to 'ext/dom')
-rw-r--r--ext/dom/node.c4
-rw-r--r--ext/dom/tests/bug32615.phpt9
2 files changed, 12 insertions, 1 deletions
diff --git a/ext/dom/node.c b/ext/dom/node.c
index 8a581baa19..cba2f80b54 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -1134,7 +1134,9 @@ PHP_FUNCTION(dom_node_replace_child)
xmlUnlinkNode(oldchild);
newchild = _php_dom_insert_fragment(nodep, prevsib, nextsib, newchild, intern, newchildobj TSRMLS_CC);
- dom_reconcile_ns(nodep->doc, newchild);
+ if (newchild) {
+ dom_reconcile_ns(nodep->doc, newchild);
+ }
} else if (oldchild != newchild) {
if (newchild->doc == NULL && nodep->doc != NULL) {
xmlSetTreeDoc(newchild, nodep->doc);
diff --git a/ext/dom/tests/bug32615.phpt b/ext/dom/tests/bug32615.phpt
index 84891f3bb4..e48973429a 100644
--- a/ext/dom/tests/bug32615.phpt
+++ b/ext/dom/tests/bug32615.phpt
@@ -62,6 +62,12 @@ $frag->appendChild(new DOMElement('second'));
$frag->appendChild(new DOMElement('third'));
$root->insertBefore($frag, $node);
+echo $dom->saveXML()."\n";
+
+$frag = $dom->createDocumentFragment();
+$root = $dom->documentElement;
+$root->replaceChild($frag, $root->firstChild);
+
echo $dom->saveXML();
?>
@@ -73,3 +79,6 @@ echo $dom->saveXML();
<?xml version="1.0"?>
<root><first/><second/><third/><fourth/></root>
+<?xml version="1.0"?>
+<root><second/><third/><fourth/></root>
+