php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76524 ZipArchive memory leak (OVERWRITE flag and empty archive)
Submitted: 2018-06-24 18:43 UTC Modified: 2018-06-28 17:59 UTC
From: timok at ya dot ru Assigned:
Status: Closed Package: Zip Related
PHP Version: 5.6.36 OS:
Private report: No CVE-ID: None
 [2018-06-24 18:43 UTC] timok at ya dot ru
Description:
------------
The memory leak occurs when 
- ZipArchive is opened with ZipArchive::CREATE|ZipArchive::OVERWRITE flags, 
- it's empty,
- it's destroyed without explicit close() method call.

The leak does not occur if zip-file already exist. 

All PHP versions are affected. 

Test script:
---------------
$zip = new ZipArchive();
$zip->open(__DIR__.'/nonexistent.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);

Expected result:
----------------
Done
Warning: Unknown: Cannot destroy the zip context in Unknown on line 0

Actual result:
--------------
Done
Warning: Unknown: Cannot destroy the zip context in Unknown on line 0
[Sun Jun 24 20:52:32 2018]  Script:  '...'
/.../php-src/ext/zip/php_zip.c(1141) :  Freeing 0x7FED6E9998B8 (80 bytes), script=...
[Sun Jun 24 20:52:32 2018]  Script:  '...'
/.../php-src/main/fopen_wrappers.c(808) :  Freeing 0x7FED6E99A090 (41 bytes), script=...
=== Total 2 memory leaks detected ===



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-10 09:21 UTC] ab@php.net
Automatic comment on behalf of timok@ya.ru
Revision: http://git.php.net/?p=php-src.git;a=commit;h=08f08858f3bc62fac9150ca5b669df060b5af5a5
Log: Fix bug #76524 - ZipArchive memory leak
 [2018-07-10 09:21 UTC] ab@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC