summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-07-04 09:50:20 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-07-04 09:50:20 +0200
commita743b7ca36a5dcb48ec014d8bf7afe66e630e231 (patch)
tree33baa11875c5b7f6fb946d9d64c12e2bb5b1bc80
parent66576fc1f6cf34d658993fa5f92020bc29fe3f88 (diff)
ASan: value nan is outside the range of representable values of type 'int'
Change-Id: Icd0a383ddec97c1129a3937fbcd8c9a9e61ff8eb
-rw-r--r--sc/source/core/tool/interpr4.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 9245ff7c469a..685b9ac851e0 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -22,6 +22,7 @@
#include "interpre.hxx"
#include <rangelst.hxx>
+#include <rtl/math.hxx>
#include <sfx2/app.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/objsh.hxx>
@@ -2096,6 +2097,11 @@ double ScInterpreter::GetDoubleWithDefault(double nDefault)
sal_Int32 ScInterpreter::GetInt32()
{
double fVal = GetDouble();
+ if (rtl::math::isNan(fVal))
+ {
+ SetError(errIllegalArgument);
+ return SAL_MAX_INT32;
+ }
if (fVal > 0.0)
{
fVal = rtl::math::approxFloor( fVal);
@@ -2120,6 +2126,11 @@ sal_Int32 ScInterpreter::GetInt32()
sal_Int32 ScInterpreter::GetInt32WithDefault( sal_Int32 nDefault )
{
double fVal = GetDoubleWithDefault( nDefault);
+ if (rtl::math::isNan(fVal))
+ {
+ SetError(errIllegalArgument);
+ return SAL_MAX_INT32;
+ }
if (fVal > 0.0)
{
fVal = rtl::math::approxFloor( fVal);
@@ -2144,6 +2155,11 @@ sal_Int32 ScInterpreter::GetInt32WithDefault( sal_Int32 nDefault )
sal_Int16 ScInterpreter::GetInt16()
{
double fVal = GetDouble();
+ if (rtl::math::isNan(fVal))
+ {
+ SetError(errIllegalArgument);
+ return SAL_MAX_INT16;
+ }
if (fVal > 0.0)
{
fVal = rtl::math::approxFloor( fVal);
@@ -2168,7 +2184,7 @@ sal_Int16 ScInterpreter::GetInt16()
sal_uInt32 ScInterpreter::GetUInt32()
{
double fVal = rtl::math::approxFloor( GetDouble());
- if (fVal < 0.0 || fVal > SAL_MAX_UINT32)
+ if (rtl::math::isNan(fVal) || fVal < 0.0 || fVal > SAL_MAX_UINT32)
{
SetError( errIllegalArgument);
return SAL_MAX_UINT32;