X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/f3c0d7a59d99c2a94c6b8822291f0e42be3773c9..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/i18n/uspoof_build.cpp diff --git a/icuSources/i18n/uspoof_build.cpp b/icuSources/i18n/uspoof_build.cpp index 75c52e0b..192fb9a6 100644 --- a/icuSources/i18n/uspoof_build.cpp +++ b/icuSources/i18n/uspoof_build.cpp @@ -71,8 +71,29 @@ uspoof_openFromSource(const char *confusables, int32_t confusablesLen, // Set up a shell of a spoof detector, with empty data. SpoofData *newSpoofData = new SpoofData(*status); + + if (newSpoofData == NULL) { + *status = U_MEMORY_ALLOCATION_ERROR; + return NULL; + } + + if (U_FAILURE(*status)) { + delete newSpoofData; + return NULL; + } SpoofImpl *This = new SpoofImpl(newSpoofData, *status); + if (This == NULL) { + *status = U_MEMORY_ALLOCATION_ERROR; + delete newSpoofData; // explicit delete as the destructor for SpoofImpl won't be called. + return NULL; + } + + if (U_FAILURE(*status)) { + delete This; // no delete for newSpoofData, as the SpoofImpl destructor will delete it. + return NULL; + } + // Compile the binary data from the source (text) format. ConfusabledataBuilder::buildConfusableData(This, confusables, confusablesLen, errorType, pe, *status);