]> granicus.if.org Git - icu/commitdiff
ICU-13788 Minor coverity fixes for number code.
authorShane Carr <shane@unicode.org>
Fri, 25 May 2018 03:01:38 +0000 (03:01 +0000)
committerShane Carr <shane@unicode.org>
Fri, 25 May 2018 03:01:38 +0000 (03:01 +0000)
X-SVN-Rev: 41459

icu4c/source/i18n/dcfmtsym.cpp
icu4c/source/i18n/number_multiplier.h

index 5050cfe9aff24bfd848b0ecafa59ca789b643e33..e6785ab7a1f0537929f29b12d161b9c5fd2dcfe6 100644 (file)
@@ -98,7 +98,7 @@ static const char *gNumberElementKeys[DecimalFormatSymbols::kFormatSymbolCount]
 // Initializes this with the decimal format symbols in the default locale.
 
 DecimalFormatSymbols::DecimalFormatSymbols(UErrorCode& status)
-        : UObject(), locale() {
+        : UObject(), locale(), currPattern(NULL) {
     initialize(locale, status, TRUE);
 }
 
@@ -106,12 +106,12 @@ DecimalFormatSymbols::DecimalFormatSymbols(UErrorCode& status)
 // Initializes this with the decimal format symbols in the desired locale.
 
 DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, UErrorCode& status)
-        : UObject(), locale(loc) {
+        : UObject(), locale(loc), currPattern(NULL) {
     initialize(locale, status);
 }
 
 DecimalFormatSymbols::DecimalFormatSymbols(const Locale& loc, const NumberingSystem& ns, UErrorCode& status)
-        : UObject(), locale(loc) {
+        : UObject(), locale(loc), currPattern(NULL) {
     initialize(locale, status, FALSE, &ns);
 }
 
@@ -349,7 +349,6 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
 {
     if (U_FAILURE(status)) { return; }
     *validLocale = *actualLocale = 0;
-    currPattern = NULL;
 
     // First initialize all the symbols to the fallbacks for anything we can't find
     initialize();
@@ -477,6 +476,7 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
     UErrorCode localStatus = U_ZERO_ERROR;
     uccLen = ucurr_forLocale(locName, ucc, uccLen, &localStatus);
 
+    // TODO: Currency pattern data loading is duplicated in number_formatimpl.cpp
     if(U_SUCCESS(localStatus) && uccLen > 0) {
         char cc[4]={0};
         u_UCharsToChars(ucc, cc, uccLen);
index 15e0dd0dfda678f613222ba69c38ab8af4ae1438..82c30c78426cdbf5ddb796ad857b7d102c2e4bcf 100644 (file)
@@ -20,6 +20,8 @@ namespace impl {
 // Exported as U_I18N_API for tests
 class U_I18N_API MultiplierFormatHandler : public MicroPropsGenerator, public UMemory {
   public:
+    MultiplierFormatHandler() = default; // WARNING: Leaves object in an unusable state; call setAndChain()
+
     void setAndChain(const Scale& multiplier, const MicroPropsGenerator* parent);
 
     void processQuantity(DecimalQuantity& quantity, MicroProps& micros,