]> granicus.if.org Git - php/commitdiff
Fixed bug #36840 (Memory leak if cast operator throws an exception that is caught)
authorDmitry Stogov <dmitry@php.net>
Fri, 24 Mar 2006 10:11:49 +0000 (10:11 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 24 Mar 2006 10:11:49 +0000 (10:11 +0000)
NEWS
Zend/zend_unicode.c

diff --git a/NEWS b/NEWS
index 0c734b1a82b9326e0148a9a59014ab90485b09d5..8d437858c707ee535669f6a534ecf4b2883e0c09 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -43,5 +43,7 @@ PHP                                                                        NEWS
   the part of haystack before or after first occurence of needle. (Johannes)
 - Added possibility to check in which extension an internal function was
   defined using reflection API. (Johannes)
+- Fixed bug #36840 (Memory leak if cast operator throws an exception that is
+  caught). (Dmitry)
 - Fixed bug #36630 (umask not reset at the end of the request). (Ilia)
 - Fixed bug #34286 (__toString() behavior is inconsistent). (Marcus)
index 233f73fed7eb48292568ae01cf586a9b2c370f63..69ae8d30b79156011c0bac9705517a0cb1f9ddb5 100644 (file)
@@ -374,14 +374,18 @@ ZEND_API int zval_unicode_to_string(zval *string, UConverter *conv TSRMLS_DC)
 
     num_conv = zend_convert_from_unicode(conv, &s, &s_len, u, u_len, &status);
 
-    ZVAL_STRINGL(string, s, s_len, 0);
-
     if (U_FAILURE(status)) {
         int32_t offset = u_countChar32(u, num_conv)-1;
+
+               if (s) {
+                       efree(s);
+               }
         zend_raise_conversion_error_ex("Could not convert Unicode string to binary string", conv, offset, (UG(from_u_error_mode) & ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC);
         retval = FAILURE;
     }
 
+    ZVAL_STRINGL(string, s, s_len, 0);
+
     efree((UChar*)u);
     return retval;
 }