From 4a159179609c9e7a66f4cb241c321e4b2f0643af Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Wed, 17 Jul 2002 16:58:32 +0000 Subject: [PATCH] ICU-1962 Don't do malloc(0), which returns NULL on some platforms. new[0] will always return a pointer. X-SVN-Rev: 9229 --- icu4c/source/i18n/rbt_set.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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) {