From daf0422aff4b89c16fbc17a4503a3e8f2506b8e0 Mon Sep 17 00:00:00 2001 From: Burkov Egor Date: Tue, 21 Jan 2025 10:21:34 +0300 Subject: [PATCH] ICU-23011 Add else branch for remove possible CWE-476 --- icu4c/source/i18n/messageformat2_function_registry.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/icu4c/source/i18n/messageformat2_function_registry.cpp b/icu4c/source/i18n/messageformat2_function_registry.cpp index b4c33544dc92..11fabb94e92a 100644 --- a/icu4c/source/i18n/messageformat2_function_registry.cpp +++ b/icu4c/source/i18n/messageformat2_function_registry.cpp @@ -87,10 +87,11 @@ MFFunctionRegistry::Builder::Builder(UErrorCode& errorCode) { formattersByType = new Hashtable(); if (!(formatters != nullptr && selectors != nullptr && formattersByType != nullptr)) { errorCode = U_MEMORY_ALLOCATION_ERROR; + } else { + formatters->setValueDeleter(uprv_deleteUObject); + selectors->setValueDeleter(uprv_deleteUObject); + formattersByType->setValueDeleter(uprv_deleteUObject); } - formatters->setValueDeleter(uprv_deleteUObject); - selectors->setValueDeleter(uprv_deleteUObject); - formattersByType->setValueDeleter(uprv_deleteUObject); } MFFunctionRegistry::Builder::~Builder() {