|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61961 file_get_contents leaks when access empty file with maxlen set
Submitted: 2012-05-06 10:19 UTC Modified: 2012-05-06 11:50 UTC
From: reeze dot xia at gmail dot com Assigned: nikic
Status: Closed Package: Streams related
PHP Version: Irrelevant OS:
Private report: No CVE-ID:
 [2012-05-06 10:19 UTC] reeze dot xia at gmail dot com
when access a empty file with file_get_contents($empty_file, NULL, NULL, NULL, 

Test script:
$tmp_empty_file = __FILE__ . ".tmp";
file_put_contents($tmp_empty_file, "");

var_dump(file_get_contents($tmp_empty_file, NULL, NULL, NULL, 10));

Expected result:
string(0) ""  without memory leaks

Actual result:
string(0) ""
[Sun May  6 18:11:17 2012]  Script:  '/Users/reeze/Opensource/php-src-
/Users/reeze/Opensource/php-src-5.3/main/streams/streams.c(1360) :  Freeing 
0x10AB26F40 (11 bytes), script=/Users/reeze/Opensource/php-src-
/Users/reeze/Opensource/php-src-5.3/ext/standard/file.c(570) : Actual location 
(location was relayed)
=== Total 1 memory leaks detected ===


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-06 11:47 UTC]
Automatic comment on behalf of
Log: Fixed Bug #61961 (file_get_content leaks when access empty file with max length)
 [2012-05-06 11:50 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2012-05-06 11:50 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 22:02:05 2014 UTC