php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36840 Memory leak if cast operator throws an exception that is caught
Submitted: 2006-03-24 08:52 UTC Modified: 2006-09-26 22:37 UTC
From: andrei@php.net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 6CVS-2006-03-24 (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: andrei@php.net
New email:
PHP Version: OS:

 

 [2006-03-24 08:52 UTC] andrei@php.net
Description:
------------
If a cast operator inside try {} block throws an exception, the result of casting is never destructed and, thus, a memory leak happens.




Reproduce code:
---------------
<?php
$u = "abc \udc00 def\n";

try {
    echo (binary)$u;
} catch(UnicodeConversionException $e) {

}
?>

INI settings:

unicode_semantics = on
unicode.output_encoding = latin-1
unicode.runtime_encoding = latin-1
unicode.from_error_mode = U_CONV_ERROR_STOP | U_CONV_ERROR_EXCEPTION


Expected result:
----------------
no output

Actual result:
--------------
[Thu Mar 23 23:49:50 2006]  Script:  't.php'
/homes/andrei/dev/php-src/Zend/zend_unicode.c(253) :  Freeing 0x013EC764 (11 bytes), script=t.php
=== Total 1 memory leaks detected ===


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-24 11:13 UTC] dmitry@php.net
Fixed in CVS HEAD.
 [2006-03-27 09:33 UTC] dmitry@php.net
Re-opened.

Throwing exceptions from conversion routines is bad solution. They are called from many different places and we cannot fix every place to care about exception.
 [2006-09-26 22:37 UTC] tony2001@php.net
Doesn't seem to be valid anymore.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 06:01:34 2025 UTC