#36840 [Asn->Csd]: Memory leak if cast operator throws an exception that is caught

From: Date: Tue, 26 Sep 2006 22:37:35 +0000
Subject: #36840 [Asn->Csd]: Memory leak if cast operator throws an exception that is caught
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102774@lists.php.net to get a copy of this message
 ID:          36840
 Updated by:  tony2001@php.net
 Reported By: andrei@php.net
-Status:      Assigned
+Status:      Closed
 Bug Type:    Scripting Engine problem
 PHP Version: 6CVS-2006-03-24 (CVS)
 Assigned To: dmitry
 New Comment:

Doesn't seem to be valid anymore.


Previous Comments:
------------------------------------------------------------------------

[2006-03-27 09:33:34] 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-03-24 11:13:56] dmitry@php.net

Fixed in CVS HEAD.

------------------------------------------------------------------------

[2006-03-24 08:52:32] 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 ===



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36840&edit=1


Thread (4 messages)

« previous php.bugs (#102774) next »