1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

phar: Fix memory leak of argument in webPhar

Closes GH-20138.
This commit is contained in:
Niels Dossche
2025-10-11 13:30:49 +02:00
parent 40f4091256
commit da39975001
2 changed files with 6 additions and 1 deletions

3
NEWS
View File

@@ -15,6 +15,9 @@ PHP NEWS
. Fixed bug GH-20081 (access to uninitialized vars in preload_load()).
(Arnaud)
- Phar:
. Fix memory leak of argument in webPhar. (nielsdos)
- Random:
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)

View File

@@ -689,12 +689,15 @@ PHP_METHOD(Phar, webPhar)
rewrite_fci.retval = &retval;
if (FAILURE == zend_call_function(&rewrite_fci, &rewrite_fcc)) {
zval_ptr_dtor_str(&params);
if (!EG(exception)) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback");
}
goto cleanup_fail;
}
zval_ptr_dtor_str(&params);
if (Z_TYPE_P(rewrite_fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
goto cleanup_fail;
@@ -720,7 +723,6 @@ PHP_METHOD(Phar, webPhar)
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
cleanup_fail:
zval_ptr_dtor(&params);
if (free_pathinfo) {
efree(path_info);
}