• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From fc256953d29698ba5918c32d14fc69ea69d7e64e Mon Sep 17 00:00:00 2001
2From: Nick Wellnhofer <wellnhofer@aevum.de>
3Date: Thu, 16 Feb 2023 14:47:41 +0100
4Subject: [PATCH] malloc-fail: Fix memory leak in htmlCreateMemoryParserCtxt
5
6Found with libFuzzer, see #344.
7
8Reference:https://github.com/GNOME/libxml2/commit/fc256953d29698ba5918c32d14fc69ea69d7e64e
9Conflict:NA
10---
11 HTMLparser.c | 5 ++++-
12 1 file changed, 4 insertions(+), 1 deletion(-)
13
14diff --git a/HTMLparser.c b/HTMLparser.c
15index 0ccd6e8..7ea2e62 100644
16--- a/HTMLparser.c
17+++ b/HTMLparser.c
18@@ -5191,7 +5191,10 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
19 	return(NULL);
20
21     buf = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);
22-    if (buf == NULL) return(NULL);
23+    if (buf == NULL) {
24+	xmlFreeParserCtxt(ctxt);
25+        return(NULL);
26+    }
27
28     input = xmlNewInputStream(ctxt);
29     if (input == NULL) {
30--
312.27.0
32