diff --git a/ChangeLog b/ChangeLog index 7a50abb3..24780a0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jan 13 17:14:06 CET 2002 Daniel Veillard + + * tree.c: trying to avoid troubles when a subtree is copied + and coalesced in part with the target tree. Should fix + bug #67407 + Sun Jan 13 16:37:15 CET 2002 Daniel Veillard * valid.c: fixed validation of attributes content of type diff --git a/tree.c b/tree.c index 28f4490e..ab8532b0 100644 --- a/tree.c +++ b/tree.c @@ -2794,8 +2794,14 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent, if (node->type == XML_ELEMENT_NODE) ret->content = (void*)(long) node->content; } - if (parent != NULL) - xmlAddChild(parent, ret); + if (parent != NULL) { + xmlNodePtr tmp; + + tmp = xmlAddChild(parent, ret); + /* node could have coalesced */ + if (tmp != ret) + return(tmp); + } if (!recursive) return(ret); if (node->nsDef != NULL) @@ -2871,7 +2877,8 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) { if (ret == NULL) { q->prev = NULL; ret = p = q; - } else { + } else if (p != q) { + /* the test is required if xmlStaticCopyNode coalesced 2 text nodes */ p->next = q; q->prev = p; p = q; @@ -3856,12 +3863,14 @@ xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) { switch (cur->type) { case XML_DOCUMENT_FRAG_NODE: case XML_ELEMENT_NODE: { - xmlNodePtr last, newNode; + xmlNodePtr last, newNode, tmp; last = cur->last; newNode = xmlNewTextLen(content, len); if (newNode != NULL) { - xmlAddChild(cur, newNode); + tmp = xmlAddChild(cur, newNode); + if (tmp != newNode) + return; if ((last != NULL) && (last->next == newNode)) { xmlTextMerge(last, newNode); }