[Libreoffice-commits] core.git: sc/source

Stephan Bergmann sbergman at redhat.com
Mon Jul 4 07:50:58 UTC 2016


 sc/source/core/tool/interpr4.cxx |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit a743b7ca36a5dcb48ec014d8bf7afe66e630e231
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jul 4 09:50:20 2016 +0200

    ASan: value nan is outside the range of representable values of type 'int'
    
    Change-Id: Icd0a383ddec97c1129a3937fbcd8c9a9e61ff8eb

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 9245ff7..685b9ac 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;


More information about the Libreoffice-commits mailing list