]> granicus.if.org Git - icu/commitdiff
ICU-13158 change range check to catch NaN
authorMarkus Scherer <markus.icu@gmail.com>
Thu, 17 Aug 2017 21:37:36 +0000 (21:37 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Thu, 17 Aug 2017 21:37:36 +0000 (21:37 +0000)
X-SVN-Rev: 40341

icu4c/source/common/uniset_props.cpp

index 9f6480b54281a0aa4ff6bc75e35acb45b8e3cc84..1c28a2d84c99a33d95b293616aa33ed9e021d20a 100644 (file)
@@ -1011,7 +1011,9 @@ UnicodeSet::applyPropertyAlias(const UnicodeString& prop,
                     double value = uprv_strtod(vname.data(), &end);
                     // Anything between 0 and 255 is valid even if unused.
                     // Cast double->int only after range check.
-                    if (*end != 0 || value < 0 || 255 < value ||
+                    // We catch NaN here because comparing it with both 0 and 255 will be false
+                    // (as are all comparisons with NaN).
+                    if (*end != 0 || !(0 <= value && value <= 255) ||
                             (v = (int32_t)value) != value) {
                         // non-integral value or outside 0..255, or trailing junk
                         FAIL(ec);