Browse Source

Fix bug #32755 Segfault in replaceChild() when DocumentFragment has no children

update test
PHP-5.1
Rob Richards 22 years ago
parent
commit
334d756ffa
  1. 4
      ext/dom/node.c
  2. 9
      ext/dom/tests/bug32615.phpt

4
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);

9
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>
Loading…
Cancel
Save