Bug 1418477 - Part 1. Should check error status of unum_open. r?jfkthame draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 22 Nov 2017 11:57:53 +0900
changeset 701976 504554b99df5954750b637526dc50636971e1708
parent 701872 5378dcb45044a160fad93b02eed0c617f3324dbc
child 701977 917fe9207a0078f77fb32c12f25824f3f3a954d6
push id90324
push userbmo:m_kato@ga2.so-net.ne.jp
push dateWed, 22 Nov 2017 14:20:56 +0000
reviewersjfkthame
bugs1418477
milestone59.0a1
Bug 1418477 - Part 1. Should check error status of unum_open. r?jfkthame We don't check error of unum_open, so we should check it. Because unum_setAttribute doesn't have UErrorCode parameter. MozReview-Commit-ID: 3j7jeiKbdG
intl/unicharutil/util/ICUUtils.cpp
--- a/intl/unicharutil/util/ICUUtils.cpp
+++ b/intl/unicharutil/util/ICUUtils.cpp
@@ -95,16 +95,22 @@ ICUUtils::LocalizeNumber(double aValue,
   UChar buffer[kBufferSize];
 
   nsAutoCString langTag;
   aLangTags.GetNext(langTag);
   while (!langTag.IsEmpty()) {
     UErrorCode status = U_ZERO_ERROR;
     AutoCloseUNumberFormat format(unum_open(UNUM_DECIMAL, nullptr, 0,
                                             langTag.get(), nullptr, &status));
+    // Since unum_setAttribute have no UErrorCode parameter, we have to
+    // check error status.
+    if (U_FAILURE(status)) {
+      aLangTags.GetNext(langTag);
+      continue;
+    }
     unum_setAttribute(format, UNUM_GROUPING_USED,
                       LocaleNumberGroupingIsEnabled());
     // ICU default is a maximum of 3 significant fractional digits. We don't
     // want that limit, so we set it to the maximum that a double can represent
     // (14-16 decimal fractional digits).
     unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, 16);
     int32_t length = unum_formatDouble(format, aValue, buffer, kBufferSize,
                                        nullptr, &status);