diff options
author | Greg Beaver <cellog@php.net> | 2008-09-26 16:30:10 +0000 |
---|---|---|
committer | Greg Beaver <cellog@php.net> | 2008-09-26 16:30:10 +0000 |
commit | 08139f40b39eb83e317a24be4b16fb724e416d89 (patch) | |
tree | 4712cad9156c59cdebb4b73419fd4e168431f6d7 /ext | |
parent | 1f0cb7309bc1bdbcff30a0a77b770afd7579761e (diff) | |
download | php-git-08139f40b39eb83e317a24be4b16fb724e416d89.tar.gz |
MFB: fix bug #46178: memory leak in ext/phar
Diffstat (limited to 'ext')
-rw-r--r-- | ext/phar/phar.c | 5 | ||||
-rw-r--r-- | ext/phar/tests/bug46178.phpt | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/ext/phar/phar.c b/ext/phar/phar.c index b12628a777..4c351751f9 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -440,6 +440,11 @@ int phar_entry_delref(phar_entry_data *idata TSRMLS_DC) /* {{{ */ if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) { php_stream_close(idata->fp); } + /* if phar_get_or_create_entry_data returns a sub-directory, we have to free it */ + if (idata->internal_file->is_temp_dir) { + destroy_phar_manifest_entry((void *)idata->internal_file); + efree(idata->internal_file); + } } phar_archive_delref(idata->phar TSRMLS_CC); diff --git a/ext/phar/tests/bug46178.phpt b/ext/phar/tests/bug46178.phpt new file mode 100644 index 0000000000..9dab621485 --- /dev/null +++ b/ext/phar/tests/bug46178.phpt @@ -0,0 +1,20 @@ +--TEST-- +Phar: PHP bug #46178: "memory leak in ext/phar" +--SKIPIF-- +<?php if (!extension_loaded("phar")) die("skip"); ?> +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +<?php +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar'; + +$phar = new Phar($fname); +$phar['long/path/name.txt'] = 'hi'; +$phar->addEmptyDir('long/path'); +?> +===DONE=== +--CLEAN-- +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');?> +--EXPECT-- +===DONE===
\ No newline at end of file |