• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From f8852184a111f6c4abb38ea3d2b2b91f45347a7a Mon Sep 17 00:00:00 2001
2From: Nick Wellnhofer <wellnhofer@aevum.de>
3Date: Tue, 14 Feb 2023 13:03:13 +0100
4Subject: [PATCH] malloc-fail: Fix memory leak in xmlParseEntityDecl
5
6Found with libFuzzer, see #344.
7
8Reference:https://github.com/GNOME/libxml2/commit/f8852184a111f6c4abb38ea3d2b2b91f45347a7a
9Conflict:NA
10---
11 parser.c | 4 ++--
12 1 file changed, 2 insertions(+), 2 deletions(-)
13
14diff --git a/parser.c b/parser.c
15index 3aea3e2..37d7dec 100644
16--- a/parser.c
17+++ b/parser.c
18@@ -5518,7 +5518,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
19 			ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
20 			if (ctxt->myDoc == NULL) {
21 			    xmlErrMemory(ctxt, "New Doc failed");
22-			    return;
23+			    goto done;
24 			}
25 			ctxt->myDoc->properties = XML_DOC_INTERNAL;
26 		    }
27@@ -5589,7 +5589,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
28 			    ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
29 			    if (ctxt->myDoc == NULL) {
30 			        xmlErrMemory(ctxt, "New Doc failed");
31-				return;
32+				goto done;
33 			    }
34 			    ctxt->myDoc->properties = XML_DOC_INTERNAL;
35 			}
36--
372.27.0
38
39