From fc256953d29698ba5918c32d14fc69ea69d7e64e Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 16 Feb 2023 14:47:41 +0100 Subject: [PATCH] malloc-fail: Fix memory leak in htmlCreateMemoryParserCtxt Found with libFuzzer, see #344. --- HTMLparser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HTMLparser.c b/HTMLparser.c index 04578e70..01092a3d 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -5227,7 +5227,10 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) { return(NULL); buf = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE); - if (buf == NULL) return(NULL); + if (buf == NULL) { + xmlFreeParserCtxt(ctxt); + return(NULL); + } input = xmlNewInputStream(ctxt); if (input == NULL) {