mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
MFB: fix bug #46178: memory leak in ext/phar
This commit is contained in:
parent
1f0cb7309b
commit
08139f40b3
2 changed files with 25 additions and 0 deletions
|
@ -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);
|
||||
|
|
20
ext/phar/tests/bug46178.phpt
Normal file
20
ext/phar/tests/bug46178.phpt
Normal file
|
@ -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===
|
Loading…
Add table
Add a link
Reference in a new issue