libxml2/backport-malloc-fail-Fix-another-memory-leak-in-xmlSchemaBuck.patch
zhuofeng feb7e8218d backport upstream patches
(cherry picked from commit ec64ed27a9add0f7a9bf6ee351ad67302a60c383)
2023-06-20 11:16:46 +08:00

33 lines
919 B
Diff

From 260d6b8d77d11a20a2614eef99e88e68eaca6550 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sun, 5 Mar 2023 14:10:26 +0100
Subject: [PATCH] malloc-fail: Fix another memory leak in xmlSchemaBucketCreate
Found with libFuzzer, see #344.
Reference:https://github.com/GNOME/libxml2/commit/260d6b8d77d11a20a2614eef99e88e68eaca6550
Conflict:NA
---
xmlschemas.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/xmlschemas.c b/xmlschemas.c
index fa9d113..06bf664 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -3742,7 +3742,10 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
return(NULL);
}
}
- xmlSchemaItemListAdd(mainSchema->includes, ret);
+ if (xmlSchemaItemListAdd(mainSchema->includes, ret) < 0) {
+ xmlSchemaBucketFree(ret);
+ return(NULL);
+ }
}
/*
* Add to list of all buckets; this is used for lookup
--
2.27.0