sc/source/core/tool/token.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 15eac2ba222d2d07dfa2bb962f4bbddbcecb9dbc
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Jul 16 11:26:37 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Jul 16 15:19:32 2022 +0200

    ofz#49017 Integer-overflow
    
    Change-Id: Iadb8c0a9bccef400f1c7fb6e5f2f3444a45da480
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137119
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 1db10bc21de3..22359d060b0a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -5347,9 +5347,9 @@ sal_Int32 ScTokenArray::GetWeight() const
                 const auto pComplexRef = (*pRPN[i]).GetDoubleRef();
 
                 // Number of cells referenced divided by 10.
-                const double nNumCellsTerm =
-                    (1 + (pComplexRef->Ref2.Row() - pComplexRef->Ref1.Row())) *
-                    (1 + (pComplexRef->Ref2.Col() - pComplexRef->Ref1.Col())) 
/ 10.;
+                const double nRows = 1 + (pComplexRef->Ref2.Row() - 
pComplexRef->Ref1.Row());
+                const double nCols = 1 + (pComplexRef->Ref2.Col() - 
pComplexRef->Ref1.Col());
+                const double nNumCellsTerm = nRows * nCols / 10.0;
 
                 if (nNumCellsTerm + nResult < SAL_MAX_INT32)
                     nResult += nNumCellsTerm;

Reply via email to