diff options
author | Felipe Pena <felipe@php.net> | 2011-11-22 12:29:15 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2011-11-22 12:29:15 +0000 |
commit | 735dc01811c71fc58af56a4dd306acfc11b425a5 (patch) | |
tree | 64ed076cace54cb00897a536ce66ba20028b1910 | |
parent | 0f26db6956ca9a7c4e07753a62bc25f247717fe0 (diff) | |
download | php-git-735dc01811c71fc58af56a4dd306acfc11b425a5.tar.gz |
- Fixed memory leak in several Intl locale functions
-rw-r--r-- | NEWS | 1 | ||||
-rwxr-xr-x | ext/intl/locale/locale_methods.c | 20 |
2 files changed, 16 insertions, 5 deletions
@@ -30,6 +30,7 @@ PHP NEWS - Intl: . Fixed bug #60192 (SegFault when Collator not constructed properly). (Florian) + . Fixed memory leak in several Intl locale functions. (Felipe) - Gd: . Fixed bug #60160 (imagefill() doesn't work correctly 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 ); |