From c46b89e2432522d92d9dd59d79c00e09af14ff9b Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 13 Sep 2024 21:06:36 +0200 Subject: [PATCH] xpath: Deprecate xmlXPathEvalExpr Also check the argument instead of crashing if there's no context. --- include/libxml/xpathInternals.h | 1 + python/generator.py | 1 + xpath.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/libxml/xpathInternals.h b/include/libxml/xpathInternals.h index d1c90dff..48eb472d 100644 --- a/include/libxml/xpathInternals.h +++ b/include/libxml/xpathInternals.h @@ -516,6 +516,7 @@ XMLPUBFUN void XMLPUBFUN void xmlXPathRoot (xmlXPathParserContextPtr ctxt); +XML_DEPRECATED XMLPUBFUN void xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); XMLPUBFUN xmlChar * diff --git a/python/generator.py b/python/generator.py index 2d6abacf..b54e16e3 100755 --- a/python/generator.py +++ b/python/generator.py @@ -407,6 +407,7 @@ deprecated_funcs = { 'xmlValidatePushElement': True, 'xmlValidateRoot': True, 'xmlValidate': True, + 'xmlXPathEvalExpr': True, 'xmlXPathInit': True, 'xmlXPtrEvalRangePredicate': True, 'xmlXPtrNewCollapsedRange': True, diff --git a/xpath.c b/xpath.c index 2e649792..e3ca1e16 100644 --- a/xpath.c +++ b/xpath.c @@ -12531,6 +12531,8 @@ xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp, * xmlXPathEvalExpr: * @ctxt: the XPath Parser context * + * DEPRECATED: Internal function, don't use. + * * Parse and evaluate an XPath expression in the given context, * then push the result on the context stack */ @@ -12541,7 +12543,7 @@ xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) { #endif int oldDepth = 0; - if (ctxt == NULL) + if ((ctxt == NULL) || (ctxt->context == NULL)) return; if (ctxt->context->lastError.code != 0) return;