php.net |  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
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: stas@php.net Assigned: ilutov (profile)
Status: Closed Package: PHAR related
PHP Version: 5.5.26 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stas@php.net
New email:
PHP Version: OS:

 

 [2015-07-07 07:00 UTC] stas@php.net
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
~                 

Patches

Pull Requests

History

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

Fixed in https://github.com/php/php-src/commit/edae24313d6ea84a84b5712b505d0a7add070af7.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 18:01:31 2024 UTC