php.net |  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
Description:
------------
when access a empty file with file_get_contents($empty_file, NULL, NULL, NULL, 
10);

Test script:
---------------
<?php
$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) ""
==DONE==
[Sun May  6 18:11:17 2012]  Script:  '/Users/reeze/Opensource/php-src-
5.3/ext/standard/tests/file/bugXXXX.php'
/Users/reeze/Opensource/php-src-5.3/main/streams/streams.c(1360) :  Freeing 
0x10AB26F40 (11 bytes), script=/Users/reeze/Opensource/php-src-
5.3/ext/standard/tests/file/bugX
XXX.php
/Users/reeze/Opensource/php-src-5.3/ext/standard/file.c(570) : Actual location 
(location was relayed)
=== Total 1 memory leaks detected ===
                                                                                                                                                                           
                                                                                                                                                                           
                                                                                                                                                                           
                                                                                                                                                                           

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-06 11:47 UTC] nikic@php.net
Automatic comment on behalf of reeze.xia@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3e9923dd8d08f88740f58e54386c0f7c569a5aa6
Log: Fixed Bug #61961 (file_get_content leaks when access empty file with max length)
 [2012-05-06 11:50 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2012-05-06 11:50 UTC] nikic@php.net
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
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
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