62 lines
1.5 KiB
Diff
62 lines
1.5 KiB
Diff
diff -Naur a/tree.c b/tree.c
|
|
--- a/tree.c 2023-10-13 11:54:20.649358250 +0800
|
|
+++ b/tree.c 2023-10-13 11:49:51.522272604 +0800
|
|
@@ -4370,29 +4370,28 @@
|
|
xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
|
|
xmlNodePtr ret = NULL;
|
|
xmlNodePtr p = NULL,q;
|
|
+ xmlDtdPtr newSubset = NULL;
|
|
|
|
while (node != NULL) {
|
|
-#ifdef LIBXML_TREE_ENABLED
|
|
if (node->type == XML_DTD_NODE ) {
|
|
- if (doc == NULL) {
|
|
+#ifdef LIBXML_TREE_ENABLED
|
|
+ if ((doc == NULL) || (doc->intSubset != NULL)) {
|
|
node = node->next;
|
|
continue;
|
|
}
|
|
- if (doc->intSubset == NULL) {
|
|
- q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node );
|
|
- if (q == NULL) return(NULL);
|
|
- q->doc = doc;
|
|
- q->parent = parent;
|
|
- doc->intSubset = (xmlDtdPtr) q;
|
|
- xmlAddChild(parent, q);
|
|
- } else {
|
|
- q = (xmlNodePtr) doc->intSubset;
|
|
- xmlAddChild(parent, q);
|
|
- }
|
|
- } else
|
|
+ q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node );
|
|
+ if (q == NULL) goto error;
|
|
+ q->doc = doc;
|
|
+ q->parent = parent;
|
|
+ newSubset = (xmlDtdPtr) q;
|
|
+#else
|
|
+ node = node->next;
|
|
+ continue;
|
|
#endif /* LIBXML_TREE_ENABLED */
|
|
+ } else {
|
|
q = xmlStaticCopyNode(node, doc, parent, 1);
|
|
- if (q == NULL) return(NULL);
|
|
+ if (q == NULL) goto error;
|
|
+ }
|
|
if (ret == NULL) {
|
|
q->prev = NULL;
|
|
ret = p = q;
|
|
@@ -4404,7 +4403,13 @@
|
|
}
|
|
node = node->next;
|
|
}
|
|
+ if (newSubset != NULL)
|
|
+ doc->intSubset = newSubset;
|
|
return(ret);
|
|
+error:
|
|
+ xmlFreeNodeList(ret);
|
|
+ return(NULL);
|
|
+
|
|
}
|
|
|
|
/**
|