Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Unified Diff: source/i18n/rbnf.cpp

Issue 2440913002: Update ICU to 58.1
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/i18n/quantityformatter.cpp ('k') | source/i18n/rbt.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/i18n/rbnf.cpp
diff --git a/source/i18n/rbnf.cpp b/source/i18n/rbnf.cpp
index de260118fa8f81649daabbe40ea25d9de29509d7..fc4fd43a7bf54be1ed81a8df6cb07507a825d576 100644
--- a/source/i18n/rbnf.cpp
+++ b/source/i18n/rbnf.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1997-2015, International Business Machines Corporation
@@ -1260,9 +1262,12 @@ RuleBasedNumberFormat::parse(const UnicodeString& text,
}
result = high_result;
if (result.getType() == Formattable::kDouble) {
- int32_t r = (int32_t)result.getDouble();
- if ((double)r == result.getDouble()) {
- result.setLong(r);
+ double d = result.getDouble();
+ if (!uprv_isNaN(d) && d == uprv_trunc(d) && INT32_MIN <= d && d <= INT32_MAX) {
+ // Note: casting a double to an int when the double is too large or small
+ // to fit the destination is undefined behavior. The explicit range checks,
+ // above, are required. Just casting and checking the result value is undefined.
+ result.setLong(static_cast<int32_t>(d));
}
}
}
« no previous file with comments | « source/i18n/quantityformatter.cpp ('k') | source/i18n/rbt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698