From 7dff411df7a18be813b63c6b253034d118eff27b Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Thu, 22 Jan 2015 19:26:09 +0000 Subject: [PATCH] ICU-11452 Improve null check X-SVN-Rev: 36981 --- icu4c/source/i18n/smpdtfmt.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index 61ce20d994e..eb4376b3c24 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -328,6 +328,9 @@ class SimpleDateFormatMutableNFs : public UMemory { // NumberFormat objects. On memory allocation error returns NULL. // Caller must check for NULL return value. NumberFormat *get(const NumberFormat *nf) { + if (nf == NULL) { + return NULL; + } int32_t idx = 0; while (nodes[idx].value) { if (nf == nodes[idx].key) { @@ -337,7 +340,7 @@ class SimpleDateFormatMutableNFs : public UMemory { } U_ASSERT(idx < UDAT_FIELD_COUNT); nodes[idx].key = nf; - nodes[idx].value = (nf == NULL) ? NULL : (NumberFormat *) nf->clone(); + nodes[idx].value = (NumberFormat *) nf->clone(); return nodes[idx].value; } private: -- 2.40.0