|  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: -
Avg. Score:3.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: Assigned:
Status: Open Package: PHAR related
PHP Version: 5.5.26 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue May 21 21:01:26 2019 UTC