Bug #70005 [Opn->Csd]: Memory leak in phar_rename_archive()

From: Date: Wed, 22 Mar 2023 00:01:05 +0000
Subject: Bug #70005 [Opn->Csd]: Memory leak in phar_rename_archive()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243965@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70005&edit=1

 ID:                 70005
 Updated by:         ilutov@php.net
 Reported by:        stas@php.net
 Summary:            Memory leak in phar_rename_archive()
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            PHAR related
 Operating System:   *
 PHP Version:        5.5.26
-Assigned To:        
+Assigned To:        ilutov
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2015-07-07 07:00:34] 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
~                 


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70005&edit=1


Thread (2 messages)

« previous php.bugs (#243965) next »