diff options
author | Matt K <mattkse@gmail.com> | 2024-01-13 17:30:59 -0600 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-01-15 16:27:15 +0100 |
commit | a01288b693d220ffe9dd98721b7f13ec31f4b09b (patch) | |
tree | 9af142318f5c71c5201e30f88ff5a60557ff1382 /sc | |
parent | a5bbee0ba52bbd6cceef889108b0d3200332cbb1 (diff) |
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.kaganski@collabora.com>
(cherry picked from commit 59927dedc31eb5d51b417a02ae927eb578b90bd6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162090
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/document.cxx | 14 |
1 files changed, 9 insertions, 5 deletions
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; } |