From: Felipe Pena Date: Tue, 22 Nov 2011 12:29:15 +0000 (+0000) Subject: - Fixed memory leak in several Intl locale functions X-Git-Tag: php-5.4.0RC2~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc8c3a2d00e926a5fa6dfc3f1687c5eed5836b92;p=php - Fixed memory leak in several Intl locale functions --- diff --git a/NEWS b/NEWS index dd331e9b9b..b62459eecb 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,27 @@ PHP NEWS . Fixed bug #43200 (Interface implementation / inheritence not possible in abstract classes). (Felipe) +- CLI SAPI: + . Fixed bug #60159 (Router returns false, but POST is not passed to requested + resource). (Laruence) + . Fixed bug #55759 (memory leak when using built-in server). (Laruence) + +- Improved PHP-FPM SAPI: + . Enhance error log when the primary script can't be open. FR #60199. (fat) + . Remove EXPERIMENTAL flag. (fat) + . Added .phar to default authorized extensions. (fat) + +- BCmath: + . Fixed bug #60377 (bcscale related crashes on 64bits platforms) (shm) + +- Intl: + . Fixed memory leak in several Intl locale functions. (Felipe) + +- Mbstring + . Fixed bug #60306 (Characters lost while converting from cp936 to utf8). + (Laruence) + . Fixed possible crash in mb_ereg_search_init() using empty pattern. (Felipe) + - MS SQL: . Fixed bug #60267 (Compile failure with freetds 0.91). (Felipe) @@ -35,35 +56,17 @@ PHP NEWS . Fixed bug #60282 (Segfault when using ob_gzhandler() with open buffers). (Laruence) +- Reflection: + . Fixed bug #60357 (__toString() method triggers E_NOTICE "Array to string + conversion"). (Laruence) + - SOAP extension: . Added new SoapClient option "keep_alive". FR #60329. (Pierrick) - + - Tidy: . Fixed bug #54682 (Tidy::diagnose() NULL pointer dereference). (Maksymilian Arciemowicz, Felipe) -- Mbstring - . Fixed bug #60306 (Characters lost while converting from cp936 to utf8). - (Laruence) - . Fixed possible crash in mb_ereg_search_init() using empty pattern. (Felipe) - -- CLI SAPI: - . Fixed bug #60159 (Router returns false, but POST is not passed to requested - resource). (Laruence) - . Fixed bug #55759 (memory leak when using built-in server). (Laruence) - -- Improved PHP-FPM SAPI: - . Enhance error log when the primary script can't be open. FR #60199. (fat) - . Remove EXPERIMENTAL flag. (fat) - . Added .phar to default authorized extensions. (fat) - -- BCmath: - . Fixed bug #60377 (bcscale related crashes on 64bits platforms) (shm) - -- Reflection: - . Fixed bug #60357 (__toString() method triggers E_NOTICE "Array to string - conversion"). (Laruence) - 11 Nov 2011, PHP 5.4.0 RC1 - General improvements: . Changed silent conversion of array to string to produce a notice. (Patrick) diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 88522339be..39d162a510 100755 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -470,6 +470,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME char* disp_loc_name = NULL; int disp_loc_name_len = 0; + int free_loc_name = 0; UChar* disp_name = NULL; int32_t disp_name_len = 0; @@ -517,17 +518,18 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME if( mod_loc_name==NULL ){ mod_loc_name = estrdup( loc_name ); } + + /* Check if disp_loc_name passed , if not use default locale */ + if( !disp_loc_name){ + disp_loc_name = estrdup(INTL_G(default_locale)); + free_loc_name = 1; + } /* Get the disp_value for the given locale */ do{ disp_name = erealloc( disp_name , buflen ); disp_name_len = buflen; - /* Check if disp_loc_name passed , if not use default locale */ - if( !disp_loc_name){ - disp_loc_name = estrdup(INTL_G(default_locale)); - } - if( strcmp(tag_name , LOC_LANG_TAG)==0 ){ buflen = uloc_getDisplayLanguage ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status); } else if( strcmp(tag_name , LOC_SCRIPT_TAG)==0 ){ @@ -557,6 +559,10 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME if( mod_loc_name){ efree( mod_loc_name ); } + if (free_loc_name) { + efree(disp_loc_name); + disp_loc_name = NULL; + } RETURN_FALSE; } } while( buflen > disp_name_len ); @@ -564,6 +570,10 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME if( mod_loc_name){ efree( mod_loc_name ); } + if (free_loc_name) { + efree(disp_loc_name); + disp_loc_name = NULL; + } /* Convert display locale name from UTF-16 to UTF-8. */ intl_convert_utf16_to_utf8( &utf8value, &utf8value_len, disp_name, buflen, &status ); efree( disp_name );