ICU-7983 Resolve valgrind error when calling Calendar::createInstance().

X-SVN-Rev: 28739
This commit is contained in:
Michael Ow 2010-09-30 05:44:33 +00:00
parent 770725ba5f
commit 742f501232

View file

@ -3250,14 +3250,15 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode&
// 2). If the locale has a script designation then we ignore it,
// then remove it ( i.e. "en_Latn_US" becomes "en_US" )
char minLocaleID[ULOC_FULLNAME_CAPACITY];
char minLocaleID[ULOC_FULLNAME_CAPACITY] = { 0 };
UErrorCode myStatus = U_ZERO_ERROR;
uloc_minimizeSubtags(desiredLocale.getName(),minLocaleID,ULOC_FULLNAME_CAPACITY,&myStatus);
Locale min = Locale::createFromName(minLocaleID);
Locale useLocale;
if ( uprv_strlen(desiredLocale.getCountry()) == 0 ||
uprv_strlen(desiredLocale.getScript()) > 0 && uprv_strlen(min.getScript()) == 0 ) {
char maxLocaleID[ULOC_FULLNAME_CAPACITY];
char maxLocaleID[ULOC_FULLNAME_CAPACITY] = { 0 };
myStatus = U_ZERO_ERROR;
uloc_addLikelySubtags(desiredLocale.getName(),maxLocaleID,ULOC_FULLNAME_CAPACITY,&myStatus);
Locale max = Locale::createFromName(maxLocaleID);