Skip to content

Commit 844a046

Browse files
committed
Fix bug #67349: Locale::parseLocale Double Free
1 parent 9d49492 commit 844a046

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

ext/intl/locale/locale_methods.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
269269
grOffset = findOffset( LOC_GRANDFATHERED , loc_name );
270270
if( grOffset >= 0 ){
271271
if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
272-
tag_value = estrdup(loc_name);
273-
return tag_value;
272+
return estrdup(loc_name);
274273
} else {
275274
/* Since Grandfathered , no value , do nothing , retutn NULL */
276275
return NULL;
@@ -280,8 +279,8 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
280279
if( fromParseLocale==1 ){
281280
/* Handle singletons */
282281
if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
283-
if( strlen(loc_name)>1 && (isIDPrefix(loc_name) ==1 ) ){
284-
return (char *)loc_name;
282+
if( strlen(loc_name)>1 && (isIDPrefix(loc_name) == 1) ){
283+
return estrdup(loc_name);
285284
}
286285
}
287286

ext/intl/tests/locale_parse_locale2.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ function ut_main()
6363
//Some Invalid Tags:
6464
'de-419-DE',
6565
'a-DE',
66-
'ar-a-aaa-b-bbb-a-ccc'
66+
'ar-a-aaa-b-bbb-a-ccc',
67+
'x-AAAAAA',
6768
);
6869

6970

@@ -201,3 +202,6 @@ No values found from Locale parsing.
201202
---------------------
202203
ar-a-aaa-b-bbb-a-ccc:
203204
language : 'ar' ,
205+
---------------------
206+
x-AAAAAA:
207+
private0 : 'AAAAAA' ,

0 commit comments

Comments
 (0)