rrichards Mon Apr 18 19:08:41 2005 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/dom node.c
/php-src/ext/dom/tests bug32615.phpt
Log:
MFH: Fix bug #32755 Segfault in replaceChild() when DocumentFragment has no
children
update test
http://cvs.php.net/diff.php/php-src/ext/dom/node.c?r1=1.29.2.4&r2=1.29.2.5&ty=u
Index: php-src/ext/dom/node.c
diff -u php-src/ext/dom/node.c:1.29.2.4 php-src/ext/dom/node.c:1.29.2.5
--- php-src/ext/dom/node.c:1.29.2.4 Fri Apr 8 11:59:38 2005
+++ php-src/ext/dom/node.c Mon Apr 18 19:08:41 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: node.c,v 1.29.2.4 2005/04/08 15:59:38 rrichards Exp $ */
+/* $Id: node.c,v 1.29.2.5 2005/04/18 23:08:41 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1134,7 +1134,9 @@
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);
http://cvs.php.net/diff.php/php-src/ext/dom/tests/bug32615.phpt?r1=1.1.2.2&r2=1.1.2.3&ty=u
Index: php-src/ext/dom/tests/bug32615.phpt
diff -u php-src/ext/dom/tests/bug32615.phpt:1.1.2.2
php-src/ext/dom/tests/bug32615.phpt:1.1.2.3
--- php-src/ext/dom/tests/bug32615.phpt:1.1.2.2 Fri Apr 8 11:59:38 2005
+++ php-src/ext/dom/tests/bug32615.phpt Mon Apr 18 19:08:41 2005
@@ -62,6 +62,12 @@
$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 @@
<?xml version="1.0"?>
<root><first/><second/><third/><fourth/></root>
+<?xml version="1.0"?>
+<root><second/><third/><fourth/></root>
+
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php