diff options
author | Stanislav Malyshev <stas@php.net> | 2015-07-06 22:58:28 -0700 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2015-07-07 09:38:31 -0700 |
commit | 885edfef0a0eb1016a906d197399f92375a795e4 (patch) | |
tree | bbb00aab381acb499aef15effc844815e689d105 | |
parent | c8157619efca850889aa5aad7ca9ef32a6b4a08d (diff) | |
download | php-git-885edfef0a0eb1016a906d197399f92375a795e4.tar.gz |
Better fix for bug #69958
-rw-r--r-- | ext/phar/phar_object.c | 22 | ||||
-rw-r--r-- | ext/phar/tests/bug69958.phpt | 2 |
2 files changed, 15 insertions, 9 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 1184863de9..8cfe0c8228 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -2089,9 +2089,10 @@ static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp TSRMLS } /* }}} */ -static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool compress TSRMLS_DC) /* {{{ */ +static zval *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool compress TSRMLS_DC) /* {{{ */ { const char *oldname = NULL; + phar_archive_data *phar = *sphar; char *oldpath = NULL; char *basename = NULL, *basepath = NULL; char *newname = NULL, *newpath = NULL; @@ -2199,6 +2200,7 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c phar->fp = NULL; phar_destroy_phar_data(phar TSRMLS_CC); phar = *pphar; + *sphar = NULL; phar->refcount++; newpath = oldpath; goto its_ok; @@ -2413,17 +2415,19 @@ no_copy: phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len TSRMLS_CC); } - if ((ret = phar_rename_archive(phar, ext, 0 TSRMLS_CC))) { + if ((ret = phar_rename_archive(&phar, ext, 0 TSRMLS_CC))) { return ret; } else { - zend_hash_destroy(&(phar->manifest)); - zend_hash_destroy(&(phar->mounted_dirs)); - zend_hash_destroy(&(phar->virtual_dirs)); - if (phar->fp) { - php_stream_close(phar->fp); + if(phar != NULL) { + zend_hash_destroy(&(phar->manifest)); + zend_hash_destroy(&(phar->mounted_dirs)); + zend_hash_destroy(&(phar->virtual_dirs)); + if (phar->fp) { + php_stream_close(phar->fp); + } + efree(phar->fname); + efree(phar); } - efree(phar->fname); - efree(phar); return NULL; } } diff --git a/ext/phar/tests/bug69958.phpt b/ext/phar/tests/bug69958.phpt index d63b413c29..96f2198b14 100644 --- a/ext/phar/tests/bug69958.phpt +++ b/ext/phar/tests/bug69958.phpt @@ -1,5 +1,7 @@ --TEST-- Phar: bug #69958: Segfault in Phar::convertToData on invalid file +--XFAIL-- +Still has memory leaks, see https://bugs.php.net/bug.php?id=70005 --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); ?> --FILE-- |