From 2963a097b992a355399246d52c699e62196bb319 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 5 Feb 2024 15:35:54 +0100 Subject: [PATCH] xpath: Report malloc failure in xmlXPathTranslateFunction --- xpath.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xpath.c b/xpath.c index 2f5c843b..3bff0d59 100644 --- a/xpath.c +++ b/xpath.c @@ -8305,7 +8305,7 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) { int offset, max; int ch; const xmlChar *point; - xmlChar *cptr; + xmlChar *cptr, *content; CHECK_ARITY(3); @@ -8355,7 +8355,11 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) { } } - valuePush(ctxt, xmlXPathCacheNewString(ctxt, xmlBufContent(target))); + content = xmlBufDetach(target); + if (content == NULL) + xmlXPathPErrMemory(ctxt); + else + valuePush(ctxt, xmlXPathCacheWrapString(ctxt, content)); xmlBufFree(target); error: xmlXPathReleaseObject(ctxt->context, str);