Skip to content

Commit da39975

Browse files
committed
phar: Fix memory leak of argument in webPhar
Closes phpGH-20138.
1 parent 40f4091 commit da39975

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ PHP NEWS
1515
. Fixed bug GH-20081 (access to uninitialized vars in preload_load()).
1616
(Arnaud)
1717

18+
- Phar:
19+
. Fix memory leak of argument in webPhar. (nielsdos)
20+
1821
- Random:
1922
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)
2023

ext/phar/phar_object.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,15 @@ PHP_METHOD(Phar, webPhar)
689689
rewrite_fci.retval = &retval;
690690

691691
if (FAILURE == zend_call_function(&rewrite_fci, &rewrite_fcc)) {
692+
zval_ptr_dtor_str(&params);
692693
if (!EG(exception)) {
693694
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback");
694695
}
695696
goto cleanup_fail;
696697
}
697698

699+
zval_ptr_dtor_str(&params);
700+
698701
if (Z_TYPE_P(rewrite_fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) {
699702
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
700703
goto cleanup_fail;
@@ -720,7 +723,6 @@ PHP_METHOD(Phar, webPhar)
720723
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
721724

722725
cleanup_fail:
723-
zval_ptr_dtor(&params);
724726
if (free_pathinfo) {
725727
efree(path_info);
726728
}

0 commit comments

Comments
 (0)