ICU-2974 disallow new X[0]

X-SVN-Rev: 12343
This commit is contained in:
Vladimir Weinstein 2003-06-06 05:05:37 +00:00
parent 752e44d7d9
commit 6e059f1475

View File

@ -732,28 +732,33 @@ Locale::getAvailableLocales(int32_t& count)
if (needInit) {
int32_t locCount = uloc_countAvailable();
Locale *newLocaleList = new Locale[locCount];
if (newLocaleList == NULL) {
return NULL;
}
if(locCount) {
Locale *newLocaleList = new Locale[locCount];
if (newLocaleList == NULL) {
return NULL;
}
count = locCount;
count = locCount;
while(--locCount >= 0) {
newLocaleList[locCount].setFromPOSIXID(uloc_getAvailable(locCount));
}
while(--locCount >= 0) {
newLocaleList[locCount].setFromPOSIXID(uloc_getAvailable(locCount));
}
umtx_lock(NULL);
if(availableLocaleList == 0) {
availableLocaleListCount = count;
availableLocaleList = newLocaleList;
newLocaleList = NULL;
}
umtx_unlock(NULL);
delete []newLocaleList;
umtx_lock(NULL);
if(availableLocaleList == 0) {
availableLocaleListCount = count;
availableLocaleList = newLocaleList;
newLocaleList = NULL;
}
umtx_unlock(NULL);
delete []newLocaleList;
}
count = availableLocaleListCount;
return availableLocaleList;
} else {
count = 0;
return NULL;
}
count = availableLocaleListCount;
return availableLocaleList;
}
const char* const* Locale::getISOCountries()