summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-02-26 16:53:46 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2023-02-26 16:55:37 +0100
commit7a7c50352e8cdb40201074895f0124d7a06d4ab3 (patch)
tree80f00e56db103873f8586f8686d1ab876e46d7b6
parent8e9c5d0551ab98f7f3235e9a37ef062ab76d4917 (diff)
downloadlibxslt-7a7c50352e8cdb40201074895f0124d7a06d4ab3.tar.gz
malloc-fail: Fix memory leak in xsltParseStylesheetAttributeSet
Found with libFuzzer, see #84.
-rw-r--r--libxslt/attributes.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libxslt/attributes.c b/libxslt/attributes.c
index 28a08418..608508a8 100644
--- a/libxslt/attributes.c
+++ b/libxslt/attributes.c
@@ -421,9 +421,12 @@ xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) {
set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
if (set == NULL) {
set = xsltNewAttrSet();
- if (set == NULL)
+ if ((set == NULL) ||
+ (xmlHashAddEntry2(style->attributeSets, ncname, nsUri, set) < 0)) {
+ xsltGenericError(xsltGenericErrorContext, "memory error\n");
+ xsltFreeAttrSet(set);
return;
- xmlHashAddEntry2(style->attributeSets, ncname, nsUri, set);
+ }
}
/*