ICU-6132 Pointers for RBNF and Formattable are check for null.

X-SVN-Rev: 23211
This commit is contained in:
Michael Ow 2008-01-11 22:17:28 +00:00
parent 10ad732dbf
commit 2b9c52e17f

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007, International Business Machines Corporation and *
* Copyright (C) 2007-2008, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -1244,6 +1244,11 @@ MessageFormat::parse(const UnicodeString& source,
ParsePosition tempPos(0);
count = 0; // {sfb} reset to zero
int32_t len;
// If resultArray could not be created, exit out.
// Avoid crossing initialization of variables above.
if (resultArray == NULL) {
goto PARSE_ERROR;
}
for (int32_t i = 0; i < subformatCount; ++i) {
// match up to format
len = subformats[i].offset - patternOffset;
@ -1396,11 +1401,13 @@ MessageFormat::autoQuoteApostrophe(const UnicodeString& pattern, UErrorCode& sta
static Format* makeRBNF(URBNFRuleSetTag tag, const Locale& locale, const UnicodeString& defaultRuleSet, UErrorCode& ec) {
RuleBasedNumberFormat* fmt = new RuleBasedNumberFormat(tag, locale, ec);
if (U_SUCCESS(ec) && defaultRuleSet.length() > 0) {
if (fmt == NULL) {
ec = U_MEMORY_ALLOCATION_ERROR;
} else if (U_SUCCESS(ec) && defaultRuleSet.length() > 0) {
fmt->setDefaultRuleSet(defaultRuleSet, ec);
if (U_FAILURE(ec)) { // ignore unrecognized default rule set
ec = U_ZERO_ERROR;
}
if (U_FAILURE(ec)) { // ignore unrecognized default rule set
ec = U_ZERO_ERROR;
}
}
return fmt;
}