|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70005 Memory leak in phar_rename_archive()
Submitted: 2015-07-07 07:00 UTC Modified: 2023-03-22 00:01 UTC
Avg. Score:4.0 ± 0.8
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: Assigned: ilutov (profile)
Status: Closed Package: PHAR related
PHP Version: 5.5.26 OS: *
Private report: No CVE-ID: None
 [2015-07-07 07:00 UTC]
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:
$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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2023-03-22 00:01 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: ilutov
 [2023-03-22 00:01 UTC]
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from and re-test.
Thank you for the report, and for helping us make PHP better.

Fixed in
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Mar 23 06:03:38 2023 UTC