From: Michael Ow Date: Tue, 29 Jan 2013 01:43:30 +0000 (+0000) Subject: ICU-8451 Ensure that the error conditions are handled properly. X-Git-Tag: milestone-59-0-1~3189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44dcd1d90ade8fa46861c1a4b2fa6cf47820f6f9;p=icu ICU-8451 Ensure that the error conditions are handled properly. X-SVN-Rev: 33088 --- diff --git a/icu4c/source/i18n/region.cpp b/icu4c/source/i18n/region.cpp index 32038e2d401..1c0428300f1 100644 --- a/icu4c/source/i18n/region.cpp +++ b/icu4c/source/i18n/region.cpp @@ -102,6 +102,10 @@ void Region::loadRegionData() { UResourceBundle* groupingContainment = NULL; DecimalFormat *df = new DecimalFormat(status); + if (U_FAILURE(status)) { + umtx_unlock(&gRegionDataLock); + return; + } df->setParseIntegerOnly(TRUE); regionIDMap = uhash_open(uhash_hashUnicodeString,uhash_compareUnicodeString,NULL,&status); @@ -408,6 +412,11 @@ Region::getInstance(const char *region_code, UErrorCode &status) { loadRegionData(); + if (regionIDMap == NULL) { + status = U_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } + UnicodeString regionCodeString = UnicodeString(region_code, -1, US_INV); Region *r = (Region *)uhash_get(regionIDMap,(void *)®ionCodeString); @@ -441,6 +450,11 @@ Region::getInstance (int32_t code, UErrorCode &status) { loadRegionData(); + if (numericCodeMap == NULL) { + status = U_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } + Region *r = (Region *)uhash_iget(numericCodeMap,code); if ( !r ) { // Just in case there's an alias that's numeric, try to find it.