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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 25 23:26:41 UTC 2018


 sc/source/core/inc/interpre.hxx  |    8 +++++---
 sc/source/core/tool/interpr1.cxx |    2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

New commits:
commit adbff0473751cde45e24bc06d524e858c68cc423
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Thu Oct 25 22:31:57 2018 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Fri Oct 26 01:26:09 2018 +0200

    Introduce kScInterpreterMaxStrLen
    
    ... and use that instead of SAL_MAX_UINT16 where string operations
    are involved.
    
    Change-Id: I41248bc1a876c19cd917269e44a6e91f51e569f5
    Reviewed-on: https://gerrit.libreoffice.org/62373
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 3fb531e3d236..f63cdced71b9 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -91,6 +91,8 @@ class SharedStringPool;
 
 }
 
+constexpr sal_Int32 kScInterpreterMaxStrLen = SAL_MAX_UINT16;
+
 #define MAXSTACK      (4096 / sizeof(formula::FormulaToken*))
 
 class ScTokenStack
@@ -1079,9 +1081,9 @@ inline bool ScInterpreter::CheckStringPositionArgument( double & fVal )
         fVal = 0.0;
         return false;
     }
-    else if (fVal > SAL_MAX_UINT16)
+    else if (fVal > kScInterpreterMaxStrLen)
     {
-        fVal = static_cast<double>(SAL_MAX_UINT16);
+        fVal = static_cast<double>(kScInterpreterMaxStrLen);
         return false;
     }
     return true;
@@ -1100,7 +1102,7 @@ inline sal_Int32 ScInterpreter::GetStringPositionArgument()
 
 inline bool ScInterpreter::CheckStringResultLen( OUString& rResult, const OUString& rAdd )
 {
-    if ( rResult.getLength() + rAdd.getLength() > SAL_MAX_UINT16 )
+    if ( rResult.getLength() + rAdd.getLength() > kScInterpreterMaxStrLen )
     {
         SetError( FormulaError::StringOverflow );
         rResult.clear();
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 11fe25e89822..e6de3b6041ef 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -9430,7 +9430,7 @@ void ScInterpreter::ScRept()
         OUString aStr = GetString().getString();
         if (nCnt < 0)
             PushIllegalArgument();
-        else if (static_cast<double>(nCnt) * aStr.getLength() > SAL_MAX_UINT16)
+        else if (static_cast<double>(nCnt) * aStr.getLength() > kScInterpreterMaxStrLen)
         {
             PushError( FormulaError::StringOverflow );
         }


More information about the Libreoffice-commits mailing list