[libxml2] Use xmlNewDocText in xmlXIncludeCopyRange
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Use xmlNewDocText in xmlXIncludeCopyRange
- Date: Fri, 20 May 2022 13:15:23 +0000 (UTC)
commit 0aa8652e596a20e95ed334ac65cf15e6e9ec4b3b
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Fri May 20 14:54:49 2022 +0200
Use xmlNewDocText in xmlXIncludeCopyRange
Otherwise, the initial node of the copy could be a text node with a
NULL document. This results in the NULL document being propagated to
copies of other nodes, losing information about the dictionary in which
node data is stored, and freeing a dict-allocated string.
See discussion in !175.
xinclude.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/xinclude.c b/xinclude.c
index 303a8bca..a3aff3e6 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -988,7 +988,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
int len;
if (content == NULL) {
- tmp = xmlNewTextLen(NULL, 0);
+ tmp = xmlNewDocTextLen(target, NULL, 0);
} else {
len = index2;
if ((cur == start) && (index1 > 1)) {
@@ -997,7 +997,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
} else {
len = index2;
}
- tmp = xmlNewTextLen(content, len);
+ tmp = xmlNewDocTextLen(target, content, len);
}
/* single sub text node selection */
if (list == NULL)
@@ -1048,13 +1048,13 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
const xmlChar *content = cur->content;
if (content == NULL) {
- tmp = xmlNewTextLen(NULL, 0);
+ tmp = xmlNewDocTextLen(target, NULL, 0);
} else {
if (index1 > 1) {
content += (index1 - 1);
index1 = 0;
}
- tmp = xmlNewText(content);
+ tmp = xmlNewDocText(target, content);
}
last = list = tmp;
listParent = cur->parent;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]