sw/source/core/crsr/viscrs.cxx |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit cefe556b9198b5dba18256d30ddcfcfda03f18c8
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Jun 25 10:17:52 2024 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Jun 25 20:13:35 2024 +0200

    sw: fix crash in SwShellCursor::Show()
    
    Crashreport signature:
    
    > Fatal signal received: SIGSEGV code: 1 for address: 0x0
    > program/libswlo.so
    >       SwShellCursor::Show(SfxViewShell const*)
    >               sw/source/core/crsr/viscrs.cxx:991
    > program/libswlo.so
    >       SwCursorShell::ShowCursors(bool)
    >               sw/source/core/crsr/crsrsh.cxx:2769
    > program/libswlo.so
    >       SwViewShell::ImplEndAction(bool)
    >               sw/source/core/view/viewsh.cxx:?
    > program/libswlo.so
    >       SwViewShell::EndAction(bool)
    >               sw/inc/viewsh.hxx:638
    
    Change-Id: I31e453fae20957b906ff82f967dd97bb571d58d8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169509
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 090d0eb70421..d8cca3cfa1b8 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -988,7 +988,19 @@ void SwShellCursor::Show(SfxViewShell const * pViewShell)
     }
     else
     {
-        
GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION,
 sRect);
+        const SwCursorShell* pShell = GetShell();
+        if (!pShell)
+        {
+            return;
+        }
+
+        SfxViewShell* pSfxViewShell = pShell->GetSfxViewShell();
+        if (!pSfxViewShell)
+        {
+            return;
+        }
+
+        pSfxViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, 
sRect);
         SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), 
LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
     }
 }

Reply via email to