summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2004-10-07 10:00:39 +0000
committerRob Richards <rrichards@php.net>2004-10-07 10:00:39 +0000
commitb0ffa2497b97be382fe1418a0f1da920fe10b8b5 (patch)
tree111ba989215652738c54b7a63e3127430dd855cc
parentd8cd7e848d0e271c1fdd37e1ae52179bb21a9eb3 (diff)
downloadphp-git-b0ffa2497b97be382fe1418a0f1da920fe10b8b5.tar.gz
fix segfault in appendXML due to libxml bug
-rw-r--r--ext/dom/documentfragment.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c
index 0fed1a81d4..c4501db30f 100644
--- a/ext/dom/documentfragment.c
+++ b/ext/dom/documentfragment.c
@@ -75,6 +75,38 @@ PHP_METHOD(domdocumentfragment, __construct)
}
/* }}} end DOMDocumentFragment::__construct */
+/* php_dom_xmlSetTreeDoc is a custom implementation of xmlSetTreeDoc
+ needed for hack in appendXML due to libxml bug - no need to share this function */
+static void php_dom_xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) {
+ xmlAttrPtr prop;
+ xmlNodePtr cur;
+
+ if (tree) {
+ if(tree->type == XML_ELEMENT_NODE) {
+ prop = tree->properties;
+ while (prop != NULL) {
+ prop->doc = doc;
+ if (prop->children) {
+ cur = prop->children;
+ while (cur != NULL) {
+ php_dom_xmlSetTreeDoc(cur, doc);
+ cur = cur->next;
+ }
+ }
+ prop = prop->next;
+ }
+ }
+ if (tree->children != NULL) {
+ cur = tree->children;
+ while (cur != NULL) {
+ php_dom_xmlSetTreeDoc(cur, doc);
+ cur = cur->next;
+ }
+ }
+ tree->doc = doc;
+ }
+}
+
/* {{{ proto void DOMDocumentFragment::appendXML(string data); */
PHP_METHOD(domdocumentfragment, appendXML) {
zval *id;
@@ -96,6 +128,11 @@ PHP_METHOD(domdocumentfragment, appendXML) {
if (err != 0) {
RETURN_FALSE;
}
+ /* Following needed due to bug in libxml2 <= 2.6.14
+ ifdef after next libxml release as bug is fixed in their cvs */
+ php_dom_xmlSetTreeDoc(lst, nodep->doc);
+ /* End stupid hack */
+
xmlAddChildList(nodep,lst);
}