diff --git a/icu4c/source/i18n/rbt_rule.cpp b/icu4c/source/i18n/rbt_rule.cpp index 6a7774c3337b..174aa0be42ce 100644 --- a/icu4c/source/i18n/rbt_rule.cpp +++ b/icu4c/source/i18n/rbt_rule.cpp @@ -167,7 +167,9 @@ TransliterationRule::TransliterationRule(TransliterationRule& other) : data(other.data) { if (other.segmentsCount > 0) { segments = static_cast(uprv_malloc(other.segmentsCount * sizeof(UnicodeFunctor*))); - uprv_memcpy(segments, other.segments, (size_t)other.segmentsCount*sizeof(segments[0])); + if (segments != nullptr) { + uprv_memcpy(segments, other.segments, (size_t)other.segmentsCount*sizeof(segments[0])); + } } if (other.anteContext != nullptr) {