summaryrefslogtreecommitdiff
path: root/ext/phar
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-06-25 15:42:32 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-06-25 15:42:56 +0200
commit785497c8ba40ac8493f123934c0c316712115628 (patch)
tree8d7544314d7205cda0fe0e7730868854bba68442 /ext/phar
parentc9bc7dd110714be7d6d6e73184e21280f3896816 (diff)
downloadphp-git-785497c8ba40ac8493f123934c0c316712115628.tar.gz
Fix leaks in Phar::webPhar()
Diffstat (limited to 'ext/phar')
-rw-r--r--ext/phar/phar_object.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 881ce96cf6..3c8ba60cf6 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -681,39 +681,30 @@ PHP_METHOD(Phar, webPhar)
if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL)) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: invalid rewrite callback");
+cleanup_fail:
+ zval_ptr_dtor(&params);
if (free_pathinfo) {
efree(path_info);
}
+ efree(entry);
efree(pt);
-
RETURN_THROWS();
}
fci.param_count = 1;
fci.params = &params;
- Z_ADDREF(params);
fci.retval = &retval;
if (FAILURE == zend_call_function(&fci, &fcc)) {
if (!EG(exception)) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback");
}
-
- if (free_pathinfo) {
- efree(path_info);
- }
- efree(pt);
-
- RETURN_THROWS();
+ goto cleanup_fail;
}
if (Z_TYPE_P(fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) {
- if (free_pathinfo) {
- efree(path_info);
- }
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
- efree(pt);
- RETURN_THROWS();
+ goto cleanup_fail;
}
switch (Z_TYPE(retval)) {
@@ -734,13 +725,8 @@ PHP_METHOD(Phar, webPhar)
zend_bailout();
return;
default:
- if (free_pathinfo) {
- efree(path_info);
- }
- efree(pt);
-
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
- RETURN_THROWS();
+ goto cleanup_fail;
}
}