summaryrefslogtreecommitdiff
path: root/ext/phar/util.c
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2008-03-21 19:54:07 +0000
committerGreg Beaver <cellog@php.net>2008-03-21 19:54:07 +0000
commit891067c9750622bab7ca3af967e864c5867d7103 (patch)
tree37d599a45d2905f8c3b4aed8772272fe844a1732 /ext/phar/util.c
parent384d50b37bf0e9d82e5b8845dd6007b756d78fd8 (diff)
downloadphp-git-891067c9750622bab7ca3af967e864c5867d7103.tar.gz
fix the memleak - but this breaks the \*compressAllFiles\*() methods because of fatal flaw
in renaming implementation - see pecl-dev email for details
Diffstat (limited to 'ext/phar/util.c')
-rw-r--r--ext/phar/util.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/phar/util.c b/ext/phar/util.c
index 6f38a17c8a..092134c2bc 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -77,6 +77,7 @@ void phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool compress
char *oldname = NULL, *oldpath = NULL;
char *basename = NULL, *basepath = NULL;
char *newname = NULL, *newpath = NULL;
+ dtor_func_t save;
if (phar->flags && compress) {
char *error;
@@ -158,6 +159,12 @@ void phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool compress
zend_hash_update(&(PHAR_GLOBALS->phar_alias_map), newpath, strlen(newpath), (void*)&phar, sizeof(phar_archive_data*), NULL);
}
+ /* remove old guy, add new guy */
+ save = PHAR_GLOBALS->phar_fname_map.pDestructor;
+ /* don't destruct, we are only renaming */
+ PHAR_GLOBALS->phar_fname_map.pDestructor = NULL;
+ zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), oldpath, phar->fname_len);
+ PHAR_GLOBALS->phar_fname_map.pDestructor = save;
zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), newpath, strlen(newpath), (void*)&phar, sizeof(phar_archive_data*), NULL);
efree(phar->fname);