From a743b7ca36a5dcb48ec014d8bf7afe66e630e231 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 4 Jul 2016 09:50:20 +0200 Subject: ASan: value nan is outside the range of representable values of type 'int' Change-Id: Icd0a383ddec97c1129a3937fbcd8c9a9e61ff8eb --- sc/source/core/tool/interpr4.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 +#include #include #include #include @@ -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; -- cgit