xzyang / rpms / libxml2

Forked from rpms/libxml2 3 years ago
Clone

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

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