From 2b9c52e17fd6e71652f04a9a0ab33605967eb87b Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Fri, 11 Jan 2008 22:17:28 +0000 Subject: [PATCH] ICU-6132 Pointers for RBNF and Formattable are check for null. X-SVN-Rev: 23211 --- icu4c/source/i18n/msgfmt.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/icu4c/source/i18n/msgfmt.cpp b/icu4c/source/i18n/msgfmt.cpp index 4a9685ac07..4d6ae007af 100644 --- a/icu4c/source/i18n/msgfmt.cpp +++ b/icu4c/source/i18n/msgfmt.cpp @@ -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; }