diff options
author | Eike Rathke <erack@redhat.com> | 2016-07-01 11:39:19 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-07-01 11:47:32 +0200 |
commit | 835fa9bd687518f44465cb22348a13984cdf779d (patch) | |
tree | 19cad55b801aa6ff58b2757ffc2456a6424a2221 /sc | |
parent | f45a78ac585b847c64c4bb78436f895b243ca2f6 (diff) |
no need to check twice
Change-Id: Iad2942851fced632c0c662bf754b1d687740105c
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index f57a9705743d..9245ff7c469a 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -2097,13 +2097,22 @@ sal_Int32 ScInterpreter::GetInt32() { double fVal = GetDouble(); if (fVal > 0.0) + { fVal = rtl::math::approxFloor( fVal); + if (fVal > SAL_MAX_INT32) + { + SetError( errIllegalArgument); + return SAL_MAX_INT32; + } + } else if (fVal < 0.0) - fVal = rtl::math::approxCeil( fVal); - if (fVal < SAL_MIN_INT32 || fVal > SAL_MAX_INT32) { - SetError( errIllegalArgument); - return SAL_MAX_INT32; + fVal = rtl::math::approxCeil( fVal); + if (fVal < SAL_MIN_INT32) + { + SetError( errIllegalArgument); + return SAL_MAX_INT32; + } } return static_cast<sal_Int32>(fVal); } @@ -2112,13 +2121,22 @@ sal_Int32 ScInterpreter::GetInt32WithDefault( sal_Int32 nDefault ) { double fVal = GetDoubleWithDefault( nDefault); if (fVal > 0.0) + { fVal = rtl::math::approxFloor( fVal); + if (fVal > SAL_MAX_INT32) + { + SetError( errIllegalArgument); + return SAL_MAX_INT32; + } + } else if (fVal < 0.0) - fVal = rtl::math::approxCeil( fVal); - if (fVal < SAL_MIN_INT32 || fVal > SAL_MAX_INT32) { - SetError( errIllegalArgument); - return SAL_MAX_INT32; + fVal = rtl::math::approxCeil( fVal); + if (fVal < SAL_MIN_INT32) + { + SetError( errIllegalArgument); + return SAL_MAX_INT32; + } } return static_cast<sal_Int32>(fVal); } @@ -2127,13 +2145,22 @@ sal_Int16 ScInterpreter::GetInt16() { double fVal = GetDouble(); if (fVal > 0.0) + { fVal = rtl::math::approxFloor( fVal); + if (fVal > SAL_MAX_INT16) + { + SetError( errIllegalArgument); + return SAL_MAX_INT16; + } + } else if (fVal < 0.0) - fVal = rtl::math::approxCeil( fVal); - if (fVal < SAL_MIN_INT16 || fVal > SAL_MAX_INT16) { - SetError( errIllegalArgument); - return SAL_MAX_INT16; + fVal = rtl::math::approxCeil( fVal); + if (fVal < SAL_MIN_INT16) + { + SetError( errIllegalArgument); + return SAL_MAX_INT16; + } } return static_cast<sal_Int16>(fVal); } |