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
--- 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);