sc/source/core/data/dociter.cxx |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 5716bb7165e8b095c202ea7a8717f2633c0d006f
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri May 19 12:17:13 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed May 31 08:56:07 2023 +0200

    sc: avoid crash in ScHorizontalCellIterator
    
    At least do not crash with release builds as seen in
    
https://crashreport.libreoffice.org/stats/signature/ScHorizontalCellIterator::ScHorizontalCellIterator(ScDocument%20&,short,short,long,short,long)
    
    Change-Id: If253e950bbb709b585dc9398beddd1303dcb1b57
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152000
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>
    (cherry picked from commit 5655cc201e5a80997fe21bc2a0c7abcbe4fb488f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152325
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 123d96d91b8c..fd4fa7afe42f 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1039,7 +1039,11 @@ 
ScHorizontalCellIterator::ScHorizontalCellIterator(ScDocument& rDocument, SCTAB
 {
     assert(mnTab < rDoc.GetTableCount() && "index out of bounds, FIX IT");
 
-    nEndCol = rDoc.maTabs[mnTab]->ClampToAllocatedColumns(nEndCol);
+    const ScTable* pTab = rDoc.FetchTable(mnTab);
+    if (!pTab)
+        return;
+
+    nEndCol = pTab->ClampToAllocatedColumns(nEndCol);
     if (nEndCol < nStartCol) // E.g., somewhere completely outside allocated 
area
         nEndCol = nStartCol - 1; // Empty
 

Reply via email to