summaryrefslogtreecommitdiffstats
path: root/sc/source/core/data/table7.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/data/table7.cxx')
-rw-r--r--sc/source/core/data/table7.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index fc821133ef65..b75751ff7de4 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -108,7 +108,8 @@ void ScTable::DeleteBeforeCopyFromClip(
ScRange aClipRange = rCxt.getClipDoc()->GetClipParam().getWholeRange();
SCCOL nClipCol = aClipRange.aStart.Col();
{
- for (SCCOL nCol = aRange.mnCol1; nCol <= aRange.mnCol2; ++nCol, ++nClipCol)
+ const SCCOL nMaxCol2 = std::min<SCCOL>( aRange.mnCol2, aCol.size() - 1 );
+ for (SCCOL nCol = aRange.mnCol1; nCol <= nMaxCol2; ++nCol, ++nClipCol)
{
if (nClipCol > aClipRange.aEnd.Col())
nClipCol = aClipRange.aStart.Col(); // loop through columns.