1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00

tree: Another fix related to #538

Should fix #639.
This commit is contained in:
Nick Wellnhofer 2023-12-01 17:49:48 +01:00
parent 4c17804050
commit 502971cc23

4
tree.c
View File

@ -4302,6 +4302,7 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
xmlNodePtr ret = NULL;
xmlNodePtr p = NULL,q;
xmlDtdPtr newSubset = NULL;
int linkedSubset = 0;
while (node != NULL) {
#ifdef LIBXML_TREE_ENABLED
@ -4318,6 +4319,7 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
newSubset = (xmlDtdPtr) q;
xmlAddChild(parent, q);
} else {
linkedSubset = 1;
q = (xmlNodePtr) doc->intSubset;
xmlAddChild(parent, q);
}
@ -4340,6 +4342,8 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
doc->intSubset = newSubset;
return(ret);
error:
if (linkedSubset != 0)
xmlUnlinkNode((xmlNodePtr) doc->intSubset);
xmlFreeNodeList(ret);
return(NULL);
}