sc/source/core/tool/address.cxx |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

New commits:
commit dc84f265dd994b9c0c12e091bdae6a88524298df
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Aug 5 20:23:20 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Aug 21 12:28:11 2024 +0200

    ofz#70966 Integer-overflow
    
    Change-Id: If91c4db8e1180f6408ef72031299f0b88e3c9a64
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171510
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit 40f97d1cf52490e8ae1b24833af07843e47f98e8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172084
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 6b44de5f1b1a..5ad3edee405f 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -733,6 +733,9 @@ static const sal_Unicode* lcl_r1c1_get_row(
         if( isRelative )
             return nullptr;
         n = rDetails.nRow;
+
+        if (n < 0 || n >= rSheetLimits.GetMaxRowCount())
+            return nullptr;
     }
     else if( isRelative )
     {
@@ -740,15 +743,23 @@ static const sal_Unicode* lcl_r1c1_get_row(
             return nullptr;
         n += rDetails.nRow;
         pEnd++;
+
+        if (n < 0 || n >= rSheetLimits.GetMaxRowCount())
+            return nullptr;
     }
     else
     {
         *nFlags |= ScRefFlags::ROW_ABS;
+
+        if (n <= 0)
+            return nullptr;
+
         n--;
+
+        if (n >= rSheetLimits.GetMaxRowCount())
+            return nullptr;
     }
 
-    if( n < 0 || n >= rSheetLimits.GetMaxRowCount() )
-        return nullptr;
     pAddr->SetRow( static_cast<SCROW>( n ) );
     *nFlags |= ScRefFlags::ROW_VALID;
 

Reply via email to