summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-02-26 16:54:31 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2023-02-28 13:17:36 +0100
commit33edba587ddc7a2d14514f8676c34e9d31d7363f (patch)
treee2af37d468e745bbd0f620701f7738d1f37b496e
parent5fea8c7ebe21721464f7167c9624e4d457158fa8 (diff)
downloadlibxslt-33edba587ddc7a2d14514f8676c34e9d31d7363f.tar.gz
malloc-fail: Fix memory leak in xsltCopyText
Found with libFuzzer, see #84.
-rw-r--r--libxslt/transform.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libxslt/transform.c b/libxslt/transform.c
index 1180a38a..d7992605 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -1087,8 +1087,10 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
if (xmlDictOwns(ctxt->dict, cur->content))
copy->content = cur->content;
else {
- if ((copy->content = xmlStrdup(cur->content)) == NULL)
+ if ((copy->content = xmlStrdup(cur->content)) == NULL) {
+ xmlFreeNode(copy);
return NULL;
+ }
}
ctxt->lasttext = NULL;