Blame SOURCES/libxml2-CVE-2019-19956.patch

a2f31b
From 5a02583c7e683896d84878bd90641d8d9b0d0549 Mon Sep 17 00:00:00 2001
a2f31b
From: Zhipeng Xie <xiezhipeng1@huawei.com>
a2f31b
Date: Wed, 7 Aug 2019 17:39:17 +0800
a2f31b
Subject: [PATCH] Fix memory leak in xmlParseBalancedChunkMemoryRecover
a2f31b
a2f31b
When doc is NULL, namespace created in xmlTreeEnsureXMLDecl
a2f31b
is bind to newDoc->oldNs, in this case, set newDoc->oldNs to
a2f31b
NULL and free newDoc will cause a memory leak.
a2f31b
a2f31b
Found with libFuzzer.
a2f31b
a2f31b
Closes #82.
a2f31b
---
a2f31b
 parser.c | 3 ++-
a2f31b
 1 file changed, 2 insertions(+), 1 deletion(-)
a2f31b
a2f31b
diff --git a/parser.c b/parser.c
a2f31b
index 1ce1ccf1..26d9f4e3 100644
a2f31b
--- a/parser.c
a2f31b
+++ b/parser.c
a2f31b
@@ -13894,7 +13894,8 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
a2f31b
     xmlFreeParserCtxt(ctxt);
a2f31b
     newDoc->intSubset = NULL;
a2f31b
     newDoc->extSubset = NULL;
a2f31b
-    newDoc->oldNs = NULL;
a2f31b
+    if(doc != NULL)
a2f31b
+	newDoc->oldNs = NULL;
a2f31b
     xmlFreeDoc(newDoc);
a2f31b
 
a2f31b
     return(ret);
a2f31b
-- 
a2f31b
2.24.1
a2f31b