mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-191 Fix for memory leak + string allocation bugs. [thanks, bobbyr@optiosoftware.com]
X-SVN-Rev: 373
This commit is contained in:
parent
80bf06949d
commit
b55dd67c06
1 changed files with 3 additions and 4 deletions
|
@ -15,6 +15,7 @@
|
|||
*
|
||||
* Date Name Description
|
||||
* 11/18/98 stephen Creation.
|
||||
* 12/10/1999 bobbyr@optiosoftware.com Fix for memory leak + string allocation bugs
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
@ -33,7 +34,7 @@ u_locbund_new(const char *loc)
|
|||
return 0;
|
||||
|
||||
len = (loc == 0 ? strlen(uloc_getDefault()) : strlen(loc));
|
||||
result->fLocale = (char*) malloc(len);
|
||||
result->fLocale = (char*) malloc(len + 1);
|
||||
if(result->fLocale == 0) {
|
||||
free(result);
|
||||
return 0;
|
||||
|
@ -61,7 +62,7 @@ u_locbund_clone(const ULocaleBundle *bundle)
|
|||
if(result == 0)
|
||||
return 0;
|
||||
|
||||
result->fLocale = (char*) malloc(strlen(bundle->fLocale));
|
||||
result->fLocale = (char*) malloc(strlen(bundle->fLocale) + 1);
|
||||
if(result->fLocale == 0) {
|
||||
free(result);
|
||||
return 0;
|
||||
|
@ -69,8 +70,6 @@ u_locbund_clone(const ULocaleBundle *bundle)
|
|||
|
||||
strcpy(result->fLocale, bundle->fLocale );
|
||||
|
||||
result->fLocale = bundle->fLocale;
|
||||
|
||||
result->fNumberFormat = (bundle->fNumberFormat == 0 ? 0 :
|
||||
unum_clone(bundle->fNumberFormat, &status));
|
||||
result->fPercentFormat = (bundle->fPercentFormat == 0 ? 0 :
|
||||
|
|
Loading…
Add table
Reference in a new issue