From 1e2387c56347e60603c29adc77366f1fea9ce91e Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 27 Oct 2019 07:41:56 +0100 Subject: [PATCH] Check result of call to xmlAddChild to fix memory leak reported in #1764. --- coders/msl.c | 4 +++- coders/svg.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/coders/msl.c b/coders/msl.c index c2293555f..514356796 100644 --- a/coders/msl.c +++ b/coders/msl.c @@ -7715,7 +7715,9 @@ static void MSLCDataBlock(void *context,const xmlChar *value,int length) xmlTextConcat(child,value,length); return; } - (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length)); + child=xmlNewCDataBlock(parser->myDoc,value,length); + if (xmlAddChild(parser->node,child) == (xmlNodePtr) NULL) + xmlFreeNode(child); } static void MSLExternalSubset(void *context,const xmlChar *name, diff --git a/coders/svg.c b/coders/svg.c index 666900084..48fcd3b1b 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -3107,7 +3107,9 @@ static void SVGCDataBlock(void *context,const xmlChar *value,int length) xmlTextConcat(child,value,length); return; } - (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length)); + child=xmlNewCDataBlock(parser->myDoc,value,length); + if (xmlAddChild(parser->node,child) == (xmlNodePtr) NULL) + xmlFreeNode(child); } static void SVGExternalSubset(void *context,const xmlChar *name, -- 2.49.0