summaryrefslogtreecommitdiff
path: root/SAX2.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-01-22 11:28:46 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2023-01-24 11:32:15 +0100
commitb3b53dcce479a825fd34095744028711e9bd741a (patch)
tree9fb899dd7486ae5791ece55d621935537e6ffd85 /SAX2.c
parent33d4a0fe4068c101a0fcbc968dae509db1d94322 (diff)
downloadlibxml2-b3b53dcce479a825fd34095744028711e9bd741a.tar.gz
malloc-fail: Fix null deref in xmlSAX2Text
Found with libFuzzer, see #344.
Diffstat (limited to 'SAX2.c')
-rw-r--r--SAX2.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/SAX2.c b/SAX2.c
index 693a9ba3..b253ea70 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2655,7 +2655,8 @@ xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
/* Mixed content, first time */
if (type == XML_TEXT_NODE) {
lastChild = xmlSAX2TextNode(ctxt, ch, len);
- lastChild->doc = ctxt->myDoc;
+ if (lastChild != NULL)
+ lastChild->doc = ctxt->myDoc;
} else
lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len);
if (lastChild != NULL) {