php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75649 fgets second parameter causes memory leak
Submitted: 2017-12-07 17:46 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: zoolyka at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 5.6.32 OS: ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zoolyka at gmail dot com
New email:
PHP Version: OS:

 

 [2017-12-07 17:46 UTC] zoolyka at gmail dot com
Description:
------------
If I specify a larger number then 8192 for fgets's length then PHP process starts to eat memory.

Test script:
---------------
<?php

$handle = fopen('multi_gb_file', 'r');
while (
  ! feof($handle)
) {
  $buffer = fgets($handle, 10485760);
}
fclose($handle);

?>

Expected result:
----------------
If length is much more then 8192 and the opened file is really huge then memory usage will rise up to the size of the readed file's size.


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Fri Oct 19 15:01:26 2018 UTC