sc/source/core/data/table2.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2198fd843b71ea6c8152f882b107eac7b3edd647
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Fri Jul 14 18:41:31 2023 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Jul 17 23:57:33 2023 +0200

    tdf#156286 sc: fix crash with column deletion
    
    Skip negative indices, which caused the crash, when
    more columns were deleted, than the remaining columns
    before them.
    
    Regression from commit dd8e061406fac581d399da088c7f0187278035dc
    "tdf#153437 sc: fix broken formatting without performance regression".
    
    Change-Id: I223e2fbb321fc4bd2ddb7a67a16a64c69e1e7872
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154445
    Reviewed-by: Czeber László <czeber.laszloa...@nisz.hu>
    Tested-by: Jenkins
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit e4ae409b8e57f5efe53af7bacd08b0d226a0d96f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154538

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index ee65a31ab6bf..027e2b424544 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -401,7 +401,7 @@ void ScTable::DeleteCol(
         for (SCCOL nCol = nStartCol + nSize; nCol < aCol.size(); ++nCol)
             aCol[nCol].SwapCol(aCol[nCol - nSize]);
         // When delete column(s), initialize the last columns from the default 
attributes
-        for (SCCOL nCol = aCol.size() - nSize; nCol < aCol.size(); ++nCol)
+        for (SCCOL nCol = aCol.size() < static_cast<SCCOL>(nSize) ? 0 : 
aCol.size() - nSize; nCol < aCol.size(); ++nCol)
             aCol[nCol].Init(nCol, aCol[nCol].GetTab(), rDocument, false);
     }
     else

Reply via email to