Bug #70005 [NEW]: Memory leak in phar_rename_archive()
From: stas
Operating system: *
PHP version: 5.5.26
Package: PHAR related
Bug Type: Bug
Bug description:Memory leak in phar_rename_archive()
Description:
------------
When fixing bug #69958, I've discovered the script below leaks memory.
This happens because phar_rename_archive() in the middle of the
procedure frees the passed argument, so after that the structure in
phar_convert_to_other() can not be freed, since it would lead to
double-free. However, the files used are still not closed. I don't
understand that code enough, so somebody more familiar with it has to
take a look.
Test script:
---------------
<?php
$tarphar = new PharData(__DIR__.'/bug69958.tar');
$phar = $tarphar->convertToData(Phar::TAR);
Expected result:
----------------
No memory leaks
Actual result:
--------------
/Users/smalyshev/php-5.5/main/streams/streams.c(530) : Stream of type
'STDIO' 0x107ef3650
(path:/private/var/folders/7_/vp26f8sn2ld0brwt8yffkbvm0000gp/T/phpCGNB7i)
was not closed
/Users/smalyshev/php-5.5/main/streams/streams.c(530) : Stream of type
'STDIO' 0x107ef0db8
(path:/Users/smalyshev/php-5.5/ext/phar/tests/bug69958.tar) was not
closed
~
--
Edit bug report at https://bugs.php.net/bug.php?id=70005&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70005&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70005&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70005&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70005&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70005&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70005&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70005&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70005&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70005&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70005&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70005&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70005&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70005&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70005&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70005&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70005&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70005&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70005&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70005&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70005&r=mysqlcfg
Thread (2 messages)
- stas@php.net