]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/uspoof_conf.cpp
ICU-64260.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / uspoof_conf.cpp
index f478afad83adb46996f4220b950cdfb99ef927ad..1a7cdad60ac42d817f0e6c9e40b279a270731e4a 100644 (file)
@@ -76,6 +76,10 @@ SPUString::~SPUString() {
 
 SPUStringPool::SPUStringPool(UErrorCode &status) : fVec(NULL), fHash(NULL) {
     fVec = new UVector(status);
 
 SPUStringPool::SPUStringPool(UErrorCode &status) : fVec(NULL), fHash(NULL) {
     fVec = new UVector(status);
+    if (fVec == NULL) {
+        status = U_MEMORY_ALLOCATION_ERROR;
+        return;
+    }
     fHash = uhash_open(uhash_hashUnicodeString,           // key hash function
                        uhash_compareUnicodeString,        // Key Comparator
                        NULL,                              // Value Comparator
     fHash = uhash_open(uhash_hashUnicodeString,           // key hash function
                        uhash_compareUnicodeString,        // Key Comparator
                        NULL,                              // Value Comparator
@@ -136,6 +140,10 @@ SPUString *SPUStringPool::addString(UnicodeString *src, UErrorCode &status) {
         delete src;
     } else {
         hashedString = new SPUString(src);
         delete src;
     } else {
         hashedString = new SPUString(src);
+        if (hashedString == NULL) {
+            status = U_MEMORY_ALLOCATION_ERROR;
+            return NULL;
+        }
         uhash_put(fHash, src, hashedString, &status);
         fVec->addElement(hashedString, status);
     }
         uhash_put(fHash, src, hashedString, &status);
         fVec->addElement(hashedString, status);
     }
@@ -160,11 +168,32 @@ ConfusabledataBuilder::ConfusabledataBuilder(SpoofImpl *spImpl, UErrorCode &stat
     if (U_FAILURE(status)) {
         return;
     }
     if (U_FAILURE(status)) {
         return;
     }
-    fTable    = uhash_open(uhash_hashLong, uhash_compareLong, NULL, &status);
-    fKeySet     = new UnicodeSet();
-    fKeyVec     = new UVector(status);
-    fValueVec   = new UVector(status);
+
+    fTable = uhash_open(uhash_hashLong, uhash_compareLong, NULL, &status);
+
+    fKeySet = new UnicodeSet();
+    if (fKeySet == NULL) {
+        status = U_MEMORY_ALLOCATION_ERROR;
+        return;
+    }
+
+    fKeyVec = new UVector(status);
+    if (fKeyVec == NULL) {
+        status = U_MEMORY_ALLOCATION_ERROR;
+        return;
+    }
+
+    fValueVec = new UVector(status);
+    if (fValueVec == NULL) {
+        status = U_MEMORY_ALLOCATION_ERROR;
+        return;
+    }
+
     stringPool = new SPUStringPool(status);
     stringPool = new SPUStringPool(status);
+    if (stringPool == NULL) {
+        status = U_MEMORY_ALLOCATION_ERROR;
+        return;
+    }
 }
 
 
 }
 
 
@@ -396,6 +425,7 @@ void ConfusabledataBuilder::outputData(UErrorCode &status) {
     for (i=0; i<numKeys; i++) {
         int32_t key =  fKeyVec->elementAti(i);
         UChar32 codePoint = ConfusableDataUtils::keyToCodePoint(key);
     for (i=0; i<numKeys; i++) {
         int32_t key =  fKeyVec->elementAti(i);
         UChar32 codePoint = ConfusableDataUtils::keyToCodePoint(key);
+        (void)previousCodePoint;    // Suppress unused variable warning.
         // strictly greater because there can be only one entry per code point
         U_ASSERT(codePoint > previousCodePoint);
         keys[i] = key;
         // strictly greater because there can be only one entry per code point
         U_ASSERT(codePoint > previousCodePoint);
         keys[i] = key;