sc/source/ui/view/viewdata.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit de0c7c099710d966725b820c0781029ab80b3cd5
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Jan 13 08:56:29 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jan 17 10:58:49 2023 +0000

    sc: fix crash in ScViewData::GetCurXForTab()
    
    Crashreport signature:
    
    program/libsclo.so
            ScViewData::GetCurXForTab(short) const
                    sc/source/ui/view/viewdata.cxx:1431
    program/libsclo.so
            ScViewFunc::OnLOKInsertDeleteColumn(short, long)
                    sc/source/ui/view/viewfunc.cxx:1552
    program/libsclo.so
            ScDocFunc::InsertCells(ScRange const&, ScMarkData const*, 
InsCellCmd, bool, bool, bool)
                    source/ui/docshell/docfunc.cxx:2256
    program/libsclo.so
            ScViewFunc::InsertCells(InsCellCmd, bool, bool)
                    sc/source/ui/view/viewfunc.cxx:1658
    
    Seeing that e.g. ScViewData::WriteUserDataSequence() already checks if
    the pointer in maTabData is a nullptr, do the same here.
    
    Change-Id: I0ebdba8c8a5bedd3c3c57c36bdf0632e2fee45c9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145431
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Marco Cecchetti <marco.cecche...@collabora.com>

diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 26387834f45a..1f2991e23fb3 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1425,7 +1425,7 @@ SCROW ScViewData::GetPosY( ScVSplitPos eWhich, SCTAB 
nForTab ) const
 
 SCCOL ScViewData::GetCurXForTab( SCTAB nTabIndex ) const
 {
-    if (!ValidTab(nTabIndex) || (nTabIndex >= 
static_cast<SCTAB>(maTabData.size())))
+    if (!ValidTab(nTabIndex) || (nTabIndex >= 
static_cast<SCTAB>(maTabData.size())) || !maTabData[nTabIndex])
         return -1;
 
     return maTabData[nTabIndex]->nCurX;

Reply via email to