From eb896f7b9e02927415b69c0a60468012920f6b3d Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Wed, 9 Jan 2008 22:58:45 +0000 Subject: [PATCH] ICU-6132 Check for fmt null pointer. X-SVN-Rev: 23197 --- icu4c/source/i18n/currfmt.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/icu4c/source/i18n/currfmt.cpp b/icu4c/source/i18n/currfmt.cpp index e2fc5a8f202..b8217ee4484 100644 --- a/icu4c/source/i18n/currfmt.cpp +++ b/icu4c/source/i18n/currfmt.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2004-2006, International Business Machines +* Copyright (c) 2004-2008, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Author: Alan Liu @@ -28,7 +28,9 @@ CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) : } CurrencyFormat::~CurrencyFormat() { - delete fmt; + if (fmt != NULL) { + delete fmt; + } } UBool CurrencyFormat::operator==(const Format& other) const { @@ -50,13 +52,20 @@ UnicodeString& CurrencyFormat::format(const Formattable& obj, UnicodeString& appendTo, FieldPosition& pos, UErrorCode& ec) const { - return fmt->format(obj, appendTo, pos, ec); + if (fmt != NULL) { + return fmt->format(obj, appendTo, pos, ec); + } + // Set error code + ec = U_ILLEGAL_ARGUMENT_ERROR; + return appendTo; } void CurrencyFormat::parseObject(const UnicodeString& source, Formattable& result, ParsePosition& pos) const { - fmt->parseCurrency(source, result, pos); + if (fmt != NULL) { + fmt->parseCurrency(source, result, pos); + } } UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyFormat)