diff --git a/icu4c/source/i18n/rbt_set.cpp b/icu4c/source/i18n/rbt_set.cpp index 76ee89ec13a..241a32ddbbf 100644 --- a/icu4c/source/i18n/rbt_set.cpp +++ b/icu4c/source/i18n/rbt_set.cpp @@ -317,6 +317,12 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status) /* Freeze things into an array. */ uprv_free(rules); // Contains alias pointers + + /* You can't do malloc(0)! */ + if (v.size() == 0) { + rules = NULL; + return; + } rules = (TransliterationRule **)uprv_malloc(v.size() * sizeof(TransliterationRule *)); /* test for NULL */ if (rules == 0) {