[php-src] master: Fix potential memory leak in XPath evaluation results
| From: | Niels Dossche | Date: | Thu, 14 Mar 2024 20:27:25 +0000 |
| Subject: | [php-src] master: Fix potential memory leak in XPath evaluation results | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127736@lists.php.net to get a copy of this message | ||
Author: Niels Dossche (nielsdos)
Date: 2024-03-14T21:08:25+01:00
Commit: https://github.com/php/php-src/commit/30c58aba0c481e52da16d87547a14e33cce373ee
Raw diff: https://github.com/php/php-src/commit/30c58aba0c481e52da16d87547a14e33cce373ee.diff
Fix potential memory leak in XPath evaluation results
Changed paths:
M NEWS
M ext/dom/xpath.c
Diff:
diff --git a/NEWS b/NEWS
index ea7909695d14a..60f6f0f7203df 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ PHP NEWS
- DOM:
. Add some missing ZPP checks. (nielsdos)
+ . Fix potential memory leak in XPath evaluation results. (nielsdos)
- Gettext:
. Fixed sigabrt raised with dcgettext/dcngettext calls with gettext 0.22.5
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index 73ceb49362781..22a7e0ecc5a91 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);
}