php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34065 throw in foreach causes memory leaks
Submitted: 2005-08-10 12:06 UTC Modified: 2006-09-19 21:44 UTC
Votes:10
Avg. Score:4.5 ± 0.7
Reproduced:7 of 9 (77.8%)
Same Version:3 (42.9%)
Same OS:5 (71.4%)
From: dmitry@php.net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 6CVS, 5CVS (2005-08-23) OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dmitry@php.net
New email:
PHP Version: OS:

 

 [2005-08-10 12:06 UTC] dmitry@php.net
Description:
------------
Throwing exception from inside a foreach block can produce memory leaks, because ZEND_SWITCH_FREE opcode is not executed.

Reproduce code:
---------------
<?php
$data = file(__FILE__);
try {
  foreach ($data as $line) {
    throw new Exception("error");
  }
} catch (Exception $e) {
  echo "ok\n";
}
?>


Expected result:
----------------
ok

Actual result:
--------------
memory leaks

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-28 09:20 UTC] dmitry@php.net
See also bug #38623
 [2006-09-19 21:44 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_2.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC