From 4022f87eb8716155291543efaaf289e51d7cbf43 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 23 Jan 2017 14:36:20 -0800 Subject: Update safe numerics package to get bitwise ops Fix callers conventions to avoid ambiguity. Fix bad bounds check unmasked by change. Directly include headers no longer pulled in by numerics itself. Review-Url: https://codereview.chromium.org/2640143003 --- core/fxcrt/fx_basic_util.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'core/fxcrt/fx_basic_util.cpp') diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp index e52ff2ecee..f608e290a2 100644 --- a/core/fxcrt/fx_basic_util.cpp +++ b/core/fxcrt/fx_basic_util.cpp @@ -12,12 +12,6 @@ #include #include -namespace { - -const int kDefaultIntValue = 0; - -} // namespace - bool FX_atonum(const CFX_ByteStringC& strc, void* pData) { if (strc.Find('.') != -1) { FX_FLOAT* pFloat = static_cast(pData); @@ -54,18 +48,19 @@ bool FX_atonum(const CFX_ByteStringC& strc, void* pData) { // we've overflowed, reset to the default value. if (bSigned) { if (bNegative) { - if (integer.ValueOrDefault(kDefaultIntValue) > + if (integer.ValueOrDefault(0) > static_cast(std::numeric_limits::max()) + 1) { - integer = kDefaultIntValue; + integer = 0; } - } else if (integer.ValueOrDefault(kDefaultIntValue) > + } else if (integer.ValueOrDefault(0) > static_cast(std::numeric_limits::max())) { - integer = kDefaultIntValue; + integer = 0; } } // Switch back to the int space so we can flip to a negative if we need. - int value = static_cast(integer.ValueOrDefault(kDefaultIntValue)); + uint32_t uValue = integer.ValueOrDefault(0); + int32_t value = static_cast(uValue); if (bNegative) value = -value; -- cgit v1.2.3