]> granicus.if.org Git - icu/commitdiff
ICU-8451 Ensure that the error conditions are handled properly.
authorMichael Ow <mow@svn.icu-project.org>
Tue, 29 Jan 2013 01:43:30 +0000 (01:43 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Tue, 29 Jan 2013 01:43:30 +0000 (01:43 +0000)
X-SVN-Rev: 33088

icu4c/source/i18n/region.cpp

index 32038e2d4011471cba234a6c9672f8f30883b14c..1c0428300f1d65d526d6dee71c451b7dcad72ef9 100644 (file)
@@ -102,6 +102,10 @@ void Region::loadRegionData() {
     UResourceBundle* groupingContainment = NULL;\r
 \r
     DecimalFormat *df = new DecimalFormat(status);\r
+    if (U_FAILURE(status)) {\r
+        umtx_unlock(&gRegionDataLock);\r
+        return;\r
+    }\r
     df->setParseIntegerOnly(TRUE);\r
 \r
     regionIDMap = uhash_open(uhash_hashUnicodeString,uhash_compareUnicodeString,NULL,&status);\r
@@ -408,6 +412,11 @@ Region::getInstance(const char *region_code, UErrorCode &status) {
 \r
     loadRegionData();\r
 \r
+    if (regionIDMap == NULL) {\r
+        status = U_ILLEGAL_ARGUMENT_ERROR;\r
+        return NULL;\r
+    }\r
+\r
     UnicodeString regionCodeString = UnicodeString(region_code, -1, US_INV);\r
     Region *r = (Region *)uhash_get(regionIDMap,(void *)&regionCodeString);\r
 \r
@@ -441,6 +450,11 @@ Region::getInstance (int32_t code, UErrorCode &status) {
 \r
     loadRegionData();\r
 \r
+    if (numericCodeMap == NULL) {\r
+        status = U_ILLEGAL_ARGUMENT_ERROR;\r
+        return NULL;\r
+    }\r
+\r
     Region *r = (Region *)uhash_iget(numericCodeMap,code);\r
 \r
     if ( !r ) { // Just in case there's an alias that's numeric, try to find it.\r