From 2836f911e3925b3eed19b0e9f3c62be48abd1c38 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Tue, 26 Mar 2002 05:28:18 +0000 Subject: [PATCH] ICU-1733 Forgot a change from Lotus. X-SVN-Rev: 8241 --- icu4c/source/i18n/tblcoll.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/icu4c/source/i18n/tblcoll.cpp b/icu4c/source/i18n/tblcoll.cpp index 800bf1d5a5..f17ae2fcad 100644 --- a/icu4c/source/i18n/tblcoll.cpp +++ b/icu4c/source/i18n/tblcoll.cpp @@ -271,12 +271,18 @@ const UnicodeString& RuleBasedCollator::getRules() const void RuleBasedCollator::getRules(UColRuleOption delta, UnicodeString &buffer) { - int rulesize = ucol_getRulesEx(ucollator, delta, NULL, -1); - UChar *rules = (UChar*) uprv_malloc( sizeof(UChar) * (rulesize) ); + int32_t rulesize = ucol_getRulesEx(ucollator, delta, NULL, -1); - ucol_getRulesEx(ucollator, delta, rules, rulesize); - buffer.setTo(rules, rulesize); - uprv_free(rules); + if (rulesize > 0) { + UChar *rules = (UChar*) uprv_malloc( sizeof(UChar) * (rulesize) ); + + ucol_getRulesEx(ucollator, delta, rules, rulesize); + buffer.setTo(rules, rulesize); + uprv_free(rules); + } + else { + buffer.remove(); + } } void RuleBasedCollator::getVersion(UVersionInfo versionInfo) const