|  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: -
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.
Block user comment
Status: Assign to:
Bug Type:
From: zoolyka at gmail dot com
New email:
PHP Version: OS:


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

Test script:

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


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.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 06:01:26 2019 UTC