1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-10 08:58:16 +03:00

set doc on last child tree in xmlAddChildList for bug #546772. Fix problem

* tree.c: set doc on last child tree in xmlAddChildList for 
  bug #546772. Fix problem adding an attribute via with xmlAddChild 
  reported by Kris Breuker.

svn path=/trunk/; revision=3806
This commit is contained in:
Rob Richards 2008-12-31 22:13:57 +00:00
parent 5a7d8bdf71
commit 810a78b305
2 changed files with 17 additions and 5 deletions

View File

@ -1,3 +1,9 @@
Wed Dec 31 23:11:37 CET 2008 Rob Richards <rrichards@cdatazone.org>
* tree.c: set doc on last child tree in xmlAddChildList for
bug #546772. Fix problem adding an attribute via with xmlAddChild
reported by Kris Breuker.
Sun Dec 27 14:16:13 CET 2008 Rob Richards <rrichards@cdatazone.org>
* xmlwriter.c: fix indenting in xmlTextWriterFullEndElement for

16
tree.c
View File

@ -3216,7 +3216,10 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
cur = cur->next;
}
cur->parent = parent;
cur->doc = parent->doc; /* the parent may not be linked to a doc ! */
/* the parent may not be linked to a doc ! */
if (cur->doc != parent->doc) {
xmlSetTreeDoc(cur, parent->doc);
}
parent->last = cur;
return(cur);
@ -3309,9 +3312,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
if (cur->type == XML_ATTRIBUTE_NODE) {
if (parent->type != XML_ELEMENT_NODE)
return(NULL);
if (parent->properties == NULL) {
parent->properties = (xmlAttrPtr) cur;
} else {
if (parent->properties != NULL) {
/* check if an attribute with the same name exists */
xmlAttrPtr lastattr;
@ -3326,8 +3327,13 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
}
if (lastattr == (xmlAttrPtr) cur)
return(cur);
}
if (parent->properties == NULL) {
parent->properties = (xmlAttrPtr) cur;
} else {
/* find the end */
lastattr = parent->properties;
xmlAttrPtr lastattr = parent->properties;
while (lastattr->next != NULL) {
lastattr = lastattr->next;
}