diff --git a/icu4c/source/i18n/datefmt.cpp b/icu4c/source/i18n/datefmt.cpp index 825e73a742d..63b43aa67e2 100644 --- a/icu4c/source/i18n/datefmt.cpp +++ b/icu4c/source/i18n/datefmt.cpp @@ -60,7 +60,11 @@ DateFormat& DateFormat::operator=(const DateFormat& other) } else { fCalendar = NULL; } - fNumberFormat = (NumberFormat*)other.fNumberFormat->clone(); + if(other.fNumberFormat) { + fNumberFormat = (NumberFormat*)other.fNumberFormat->clone(); + } else { + fNumberFormat = NULL; + } } return *this; } @@ -88,8 +92,8 @@ DateFormat::operator==(const Format& other) const return (this == fmt) || ((getDynamicClassID() == other.getDynamicClassID()) && - fCalendar->isEquivalentTo(*fmt->fCalendar) && - (*fNumberFormat == *fmt->fNumberFormat)); + fCalendar&&(fCalendar->isEquivalentTo(*fmt->fCalendar)) && + (fNumberFormat&&(*fNumberFormat == *fmt->fNumberFormat)) ); } //---------------------------------------------------------------------- diff --git a/icu4c/source/i18n/decimfmt.cpp b/icu4c/source/i18n/decimfmt.cpp index d734effd985..9736937bc09 100644 --- a/icu4c/source/i18n/decimfmt.cpp +++ b/icu4c/source/i18n/decimfmt.cpp @@ -116,7 +116,10 @@ DecimalFormat::DecimalFormat(UErrorCode& status) fNegPrefixPattern(0), fNegSuffixPattern(0), fCurrencyChoice(0), - fSymbols(0) + fSymbols(0), fFormatWidth(0), + fPad(0), fMinExponentDigits(0), + fRoundingIncrement(0),fMultiplier(0), + fGroupingSize(0),fGroupingSize2(0) { UParseError parseError; construct(status, parseError); @@ -134,7 +137,10 @@ DecimalFormat::DecimalFormat(const UnicodeString& pattern, fNegPrefixPattern(0), fNegSuffixPattern(0), fCurrencyChoice(0), - fSymbols(0) + fSymbols(0), fFormatWidth(0), + fPad(0), fMinExponentDigits(0), + fRoundingIncrement(0),fMultiplier(0), + fGroupingSize(0),fGroupingSize2(0) { UParseError parseError; construct(status, parseError, &pattern); @@ -154,7 +160,10 @@ DecimalFormat::DecimalFormat(const UnicodeString& pattern, fNegPrefixPattern(0), fNegSuffixPattern(0), fCurrencyChoice(0), - fSymbols(0) + fSymbols(0), fFormatWidth(0), + fPad(0), fMinExponentDigits(0), + fRoundingIncrement(0),fMultiplier(0), + fGroupingSize(0),fGroupingSize2(0) { UParseError parseError; if (symbolsToAdopt == NULL) @@ -172,7 +181,10 @@ DecimalFormat::DecimalFormat( const UnicodeString& pattern, fNegPrefixPattern(0), fNegSuffixPattern(0), fCurrencyChoice(0), - fSymbols(0) + fSymbols(0), fFormatWidth(0), + fPad(0), fMinExponentDigits(0), + fRoundingIncrement(0),fMultiplier(0), + fGroupingSize(0),fGroupingSize2(0) { if (symbolsToAdopt == NULL) status = U_ILLEGAL_ARGUMENT_ERROR; @@ -192,7 +204,10 @@ DecimalFormat::DecimalFormat(const UnicodeString& pattern, fNegPrefixPattern(0), fNegSuffixPattern(0), fCurrencyChoice(0), - fSymbols(0) + fSymbols(0), fFormatWidth(0), + fPad(0), fMinExponentDigits(0), + fRoundingIncrement(0),fMultiplier(0), + fGroupingSize(0),fGroupingSize2(0) { UParseError parseError; construct(status, parseError, &pattern, new DecimalFormatSymbols(symbols)); diff --git a/icu4c/source/i18n/dtfmtsym.cpp b/icu4c/source/i18n/dtfmtsym.cpp index e8f1a89fe72..fa6d1e8a003 100644 --- a/icu4c/source/i18n/dtfmtsym.cpp +++ b/icu4c/source/i18n/dtfmtsym.cpp @@ -575,11 +575,17 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError /* In case something goes wrong, initialize all of the data to NULL. */ fEras = NULL; + fErasCount = 0; fMonths = NULL; + fMonthsCount=0; fShortMonths = NULL; + fShortMonthsCount=0; fWeekdays = NULL; + fWeekdaysCount=0; fShortWeekdays = NULL; + fShortWeekdaysCount=0; fAmPms = NULL; + fAmPmsCount=0; fZoneStringsRowCount = 0; fZoneStringsColCount = 0; fZoneStrings = NULL;