1From 7762e8eda184bc755dcc3c2d4aed259f95670ccd Mon Sep 17 00:00:00 2001
2From: Nick Wellnhofer <wellnhofer@aevum.de>
3Date: Sun, 5 Mar 2023 14:08:15 +0100
4Subject: [PATCH] malloc-fail: Fix null deref in xmlSchemaValAtomicType
5
6Found with libFuzzer, see #344.
7
8Reference:https://github.com/GNOME/libxml2/commit/7762e8eda184bc755dcc3c2d4aed259f95670ccd
9Conflict:NA
10---
11 xmlschemastypes.c | 2 ++
12 1 file changed, 2 insertions(+)
13
14diff --git a/xmlschemastypes.c b/xmlschemastypes.c
15index ebb0219..d4864b7 100644
16--- a/xmlschemastypes.c
17+++ b/xmlschemastypes.c
18@@ -3033,6 +3033,8 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
19 			    value = norm;
20 		    }
21 		    tmpval = xmlStrdup(value);
22+                    if (tmpval == NULL)
23+                        goto error;
24 		    for (cur = tmpval; *cur; ++cur) {
25 			if (*cur < 32 || *cur >= 127 || *cur == ' ' ||
26 			    *cur == '<' || *cur == '>' || *cur == '"' ||
27-- 
282.27.0
29
30