X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/fd0068a84e9996f225edba706498f6ed413d0673..46f4442e9a5a4f3b98b7c1083586332f6a8a99a4:/icuSources/i18n/fmtable.cpp?ds=sidebyside diff --git a/icuSources/i18n/fmtable.cpp b/icuSources/i18n/fmtable.cpp index b767b332..66657ff8 100644 --- a/icuSources/i18n/fmtable.cpp +++ b/icuSources/i18n/fmtable.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 1997-2006, International Business Machines Corporation and * +* Copyright (C) 1997-2008, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -70,7 +70,10 @@ static inline UBool instanceOfMeasure(const UObject* a) { */ static inline Formattable* createArrayCopy(const Formattable* array, int32_t count) { Formattable *result = new Formattable[count]; - for (int32_t i=0; i @@ -398,6 +409,10 @@ Formattable::getInt64(UErrorCode& status) const return (int64_t)fValue.fDouble; } case Formattable::kObject: + if (fValue.fObject == NULL) { + status = U_MEMORY_ALLOCATION_ERROR; + return 0; + } // TODO Later replace this with instanceof call if (instanceOfMeasure(fValue.fObject)) { return ((const Measure*) fValue.fObject)-> @@ -424,6 +439,10 @@ Formattable::getDouble(UErrorCode& status) const case Formattable::kDouble: return fValue.fDouble; case Formattable::kObject: + if (fValue.fObject == NULL) { + status = U_MEMORY_ALLOCATION_ERROR; + return 0; + } // TODO Later replace this with instanceof call if (instanceOfMeasure(fValue.fObject)) { return ((const Measure*) fValue.fObject)-> @@ -545,7 +564,11 @@ Formattable::getString(UnicodeString& result, UErrorCode& status) const setError(status, U_INVALID_FORMAT_ERROR); result.setToBogus(); } else { - result = *fValue.fString; + if (fValue.fString == NULL) { + setError(status, U_MEMORY_ALLOCATION_ERROR); + } else { + result = *fValue.fString; + } } return result; } @@ -558,6 +581,10 @@ Formattable::getString(UErrorCode& status) const setError(status, U_INVALID_FORMAT_ERROR); return *getBogus(); } + if (fValue.fString == NULL) { + setError(status, U_MEMORY_ALLOCATION_ERROR); + return *getBogus(); + } return *fValue.fString; } @@ -569,6 +596,10 @@ Formattable::getString(UErrorCode& status) setError(status, U_INVALID_FORMAT_ERROR); return *getBogus(); } + if (fValue.fString == NULL) { + setError(status, U_MEMORY_ALLOCATION_ERROR); + return *getBogus(); + } return *fValue.fString; }