From 402b662716adaf18da652504153b8ac737c78cf7 Mon Sep 17 00:00:00 2001 From: lamtung-monash Date: Tue, 16 Dec 2025 16:57:53 +0800 Subject: [PATCH] Fix memory leak in xmlParseBalancedChunkMemoryRecover When doc is NULL, namespace created in xmlTreeEnsureXMLDecl is bind to newDoc->oldNs, in this case, set newDoc->oldNs to NULL and free newDoc will cause a memory leak. --- libxml2-2.9.9/parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libxml2-2.9.9/parser.c b/libxml2-2.9.9/parser.c index 5813a6643..d12d9e8c4 100644 --- a/libxml2-2.9.9/parser.c +++ b/libxml2-2.9.9/parser.c @@ -13898,6 +13898,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax, xmlFreeParserCtxt(ctxt); newDoc->intSubset = NULL; newDoc->extSubset = NULL; + if(doc != NULL) newDoc->oldNs = NULL; xmlFreeDoc(newDoc);