summaryrefslogtreecommitdiff
path: root/xinclude.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-02-04 15:00:54 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2023-02-13 11:19:55 +0100
commitdc2dde1ab92e50766df654fa9445456adb007605 (patch)
tree7471022fb39111e2ce0e26192cac9966fa22d0cd /xinclude.c
parenta3749551e65a8caf146ea2bccf610e718d90bde0 (diff)
downloadlibxml2-dc2dde1ab92e50766df654fa9445456adb007605.tar.gz
malloc-fail: Fix null deref in xmlXIncludeLoadTxt
Found with libFuzzer, see #344.
Diffstat (limited to 'xinclude.c')
-rw-r--r--xinclude.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/xinclude.c b/xinclude.c
index 0b9f9ca6..2f4ee8cf 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -1732,6 +1732,12 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url,
xmlCharEncCloseFunc(buf->encoder);
buf->encoder = xmlGetCharEncodingHandler(enc);
node = xmlNewDocText(ctxt->doc, NULL);
+ if (node == NULL) {
+ xmlFreeInputStream(inputStream);
+ xmlFreeParserCtxt(pctxt);
+ xmlFree(URL);
+ return(-1);
+ }
/*
* Scan all chars from the resource and add the to the node