diff --git a/NEWS b/NEWS index 182c51160c9..77ba9039458 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ PHP NEWS - DOM: . Add some missing ZPP checks. (nielsdos) + . Fix potential memory leak in XPath evaluation results. (nielsdos) - FPM: . Fixed GH-11086 (FPM: config test runs twice in daemonised mode). diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 73ceb493627..22a7e0ecc5a 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -125,8 +125,11 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, } } break; - default: - ZVAL_STRING(&fci.params[i], (char *)xmlXPathCastToString(obj)); + default: { + str = (char *)xmlXPathCastToString(obj); + ZVAL_STRING(&fci.params[i], str); + xmlFree(str); + } } xmlXPathFreeObject(obj); }