php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35968 Memory leak if exception thrown within switch
Submitted: 2006-01-11 07:40 UTC Modified: 2006-01-11 08:25 UTC
From: levi at alliancesoftware dot com dot au Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2006-01-11 (CVS) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: levi at alliancesoftware dot com dot au
New email:
PHP Version: OS:

 

 [2006-01-11 07:40 UTC] levi at alliancesoftware dot com dot au
Description:
------------
A memory leak occurs if an exception is thrown within a switch($var) block

The leak does not occur if the switch is made on a constant [eg switch(5)]

Occurs in 5.0.5, but not in 5.1.1

It *does* however still appear in 5.0-CVS (2006-01-11) -- maybe the bug was 'accidentally' fixed in 5.1; I couldn't find any reference to it in the bugs list.

 If it was a deliberatel fix in 5.1, can the fix be backported to the 5.0 tree too?


Reproduce code:
---------------
#!/usr/local/src/php5/php-5.0CVS/php-src/sapi/cli/php
<?

try {
    $x = 0;
    switch ($x) {
        default:
            throw new Exception('bad thing happened');
    }
} catch (Exception $z) {
}

?>



Expected result:
----------------
Nothing

Actual result:
--------------
With --enable-debug:

/usr/local/src/php5/php-5.0CVS/php-src/Zend/zend_execute.c(675) :  Freeing 0x09A4C354 (16 byt
es), script=./tX.php5
=== Total 1 memory leaks detected ===

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-11 08:25 UTC] derick@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

The upgrade path from PHP 5.0 is PHP 5.1.1. So simply use PHP 5.1.1... Besides that, this is not a critical problem as PHP will clean it up at the end of the request.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 18 17:00:03 2025 UTC