1From 1a2d8ddc066143d256fdb8cc554707fe141dd2f6 Mon Sep 17 00:00:00 2001 2From: Nick Wellnhofer <wellnhofer@aevum.de> 3Date: Tue, 11 Oct 2022 13:02:47 +0200 4Subject: [PATCH] parser: Fix potential memory leak in xmlParseAttValueInternal 5 6Fix memory leak in case xmlParseAttValueInternal is called with a NULL 7`len` a non-NULL `alloc` argument. This static function is never called 8with such arguments internally, but the misleading code should be fixed 9nevertheless. 10 11Fixes #422. 12 13Reference:https://github.com/GNOME/libxml2/commit/1a2d8ddc066143d256fdb8cc554707fe141dd2f6 14Conflict:NA 15 16--- 17 parser.c | 2 +- 18 1 file changed, 1 insertion(+), 1 deletion(-) 19 20diff --git a/parser.c b/parser.c 21index 7bb47366..337e62f6 100644 22--- a/parser.c 23+++ b/parser.c 24@@ -9155,6 +9155,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, 25 in++; 26 col++; 27 if (len != NULL) { 28+ if (alloc) *alloc = 0; 29 *len = last - start; 30 ret = (xmlChar *) start; 31 } else { 32@@ -9164,7 +9165,6 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, 33 CUR_PTR = in; 34 ctxt->input->line = line; 35 ctxt->input->col = col; 36- if (alloc) *alloc = 0; 37 return ret; 38 need_complex: 39 if (alloc) *alloc = 1; 40-- 412.27.0 42 43