-
Notifications
You must be signed in to change notification settings - Fork 8
/
1010.diff
39 lines (34 loc) · 1.1 KB
/
1010.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
commit 074180119fc90d5fd04ef9e8a5ee1910d6f9ad8e
Author: David Tardon <[email protected]>
Date: Wed Apr 5 10:22:40 2017 +0200
Do not leak the new CData node if adding fails
For https://bugzilla.gnome.org/show_bug.cgi?id=780918
diff --git a/SAX2.c b/SAX2.c
index 5cbb700a..0f0ad2a4 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2788,24 +2788,25 @@ void
xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNodePtr ret, lastChild;
if (ctx == NULL) return;
#ifdef DEBUG_SAX
xmlGenericError(xmlGenericErrorContext,
"SAX.pcdata(%.10s, %d)\n", value, len);
#endif
lastChild = xmlGetLastChild(ctxt->node);
#ifdef DEBUG_SAX_TREE
xmlGenericError(xmlGenericErrorContext,
"add chars to %s \n", ctxt->node->name);
#endif
if ((lastChild != NULL) &&
(lastChild->type == XML_CDATA_SECTION_NODE)) {
xmlTextConcat(lastChild, value, len);
} else {
ret = xmlNewCDataBlock(ctxt->myDoc, value, len);
- xmlAddChild(ctxt->node, ret);
+ if (xmlAddChild(ctxt->node, ret) == NULL)
+ xmlFreeNode(ret);
}
}