sc/source/core/data/document.cxx |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit a381ac7b0fa95ce340bd1b384c946fbd19d87393
Author:     Matt K <matt...@gmail.com>
AuthorDate: Sat Jan 13 17:30:59 2024 -0600
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jan 15 11:45:59 2024 +0100

    tdf#151752 Fix crash when selecting unprotected cells and copy/pasting
    
    The problem is that the code attemps to index into maTabs when looping
    through clipboard ranges, but maTabs.size() can be 0 at that point
    thus resulting in a crash.  The fix is to first check if maTabs.size()
    is greater than 0 before doing the looping.
    
    Change-Id: Ib2fc4c9f847f87f44a68ad6d73c2745d79b5caa5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162032
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 59927dedc31eb5d51b417a02ae927eb578b90bd6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162090
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 060bd85eebbc..ff6d77b432f7 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3254,12 +3254,16 @@ bool ScDocument::HasClipFilteredRows()
     if ( rClipRanges.empty() )
         return false;
 
-    for ( size_t i = 0, n = rClipRanges.size(); i < n; ++i )
+    if (maTabs.size() > 0)
     {
-        ScRange & rRange = rClipRanges[ i ];
-        bool bAnswer = maTabs[nCountTab]->HasFilteredRows(rRange.aStart.Row(), 
rRange.aEnd.Row());
-        if (bAnswer)
-            return true;
+        for (size_t i = 0, n = rClipRanges.size(); i < n; ++i)
+        {
+            ScRange& rRange = rClipRanges[i];
+            bool bAnswer
+                = maTabs[nCountTab]->HasFilteredRows(rRange.aStart.Row(), 
rRange.aEnd.Row());
+            if (bAnswer)
+                return true;
+        }
     }
     return false;
 }

Reply via email to