summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-02-26 16:53:57 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2023-02-26 16:55:37 +0100
commitb5e338b396b2a002dced88a88a866a548f084741 (patch)
treedbf4bf6b947607d5a864a6fedbeedebfb3c48cf7
parent212e43452f6e4c716ea781be90122f88b5dd956e (diff)
downloadlibxslt-b5e338b396b2a002dced88a88a866a548f084741.tar.gz
malloc-fail: Fix memory leak in xsltSaveResultToString
Found with libFuzzer, see #84.
-rw-r--r--libxslt/xsltutils.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c
index 39b1b9fd..59dd192d 100644
--- a/libxslt/xsltutils.c
+++ b/libxslt/xsltutils.c
@@ -1828,6 +1828,8 @@ xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len,
(const xmlChar *) "UTF-8")))
encoder = NULL;
buf = xmlAllocOutputBuffer(encoder);
+ if (buf == NULL)
+ xmlCharEncCloseFunc(encoder);
} else {
buf = xmlAllocOutputBuffer(NULL);
}