1From 70b21c9f2a31b3ecfe8aa624c01da3ebba9e06c8 Mon Sep 17 00:00:00 2001
2From: Nick Wellnhofer <wellnhofer@aevum.de>
3Date: Sun, 26 Feb 2023 14:33:16 +0100
4Subject: [PATCH] malloc-fail: Fix null deref in xmlXPathCompiledEvalInternal
5
6Found with libFuzzer, see #344.
7
8Reference:https://github.com/GNOME/libxml2/commit/70b21c9f2a31b3ecfe8aa624c01da3ebba9e06c8
9Conflict:NA
10---
11 xpath.c | 2 ++
12 1 file changed, 2 insertions(+)
13
14diff --git a/xpath.c b/xpath.c
15index d63bdd7..54d9c58 100644
16--- a/xpath.c
17+++ b/xpath.c
18@@ -14370,6 +14370,8 @@ xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp,
19     }
20 #endif
21     pctxt = xmlXPathCompParserContext(comp, ctxt);
22+    if (pctxt == NULL)
23+        return(-1);
24     res = xmlXPathRunEval(pctxt, toBool);
25 
26     if (pctxt->error != XPATH_EXPRESSION_OK) {
27-- 
282.27.0
29
30