summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/uspoof_build.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'deps/icu-small/source/i18n/uspoof_build.cpp')
-rw-r--r--deps/icu-small/source/i18n/uspoof_build.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/deps/icu-small/source/i18n/uspoof_build.cpp b/deps/icu-small/source/i18n/uspoof_build.cpp
index 7d2440e5af..7087c1ce59 100644
--- a/deps/icu-small/source/i18n/uspoof_build.cpp
+++ b/deps/icu-small/source/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);