cvs: php-src /ext/dom documentfragment.c
| From: | Rob Richards | Date: | Thu, 07 Oct 2004 10:00:43 +0000 |
| Subject: | cvs: php-src /ext/dom documentfragment.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-28917@lists.php.net to get a copy of this message | ||
rrichards Thu Oct 7 06:00:43 2004 EDT
Modified files:
/php-src/ext/dom documentfragment.c
Log:
fix segfault in appendXML due to libxml bug
http://cvs.php.net/diff.php/php-src/ext/dom/documentfragment.c?r1=1.12&r2=1.13&ty=u
Index: php-src/ext/dom/documentfragment.c
diff -u php-src/ext/dom/documentfragment.c:1.12 php-src/ext/dom/documentfragment.c:1.13
--- php-src/ext/dom/documentfragment.c:1.12 Sun Jul 18 09:47:44 2004
+++ php-src/ext/dom/documentfragment.c Thu Oct 7 06:00:39 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: documentfragment.c,v 1.12 2004/07/18 13:47:44 rrichards Exp $ */
+/* $Id: documentfragment.c,v 1.13 2004/10/07 10:00:39 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -75,6 +75,38 @@
}
/* }}} 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 @@
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);
}