sw/source/ui/chrdlg/numpara.cxx  |   14 ++++++++------
 sw/source/uibase/inc/numpara.hxx |    2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit aff6d64609bceceef017de2a4fc8b3dd2eba6460
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Oct 3 19:00:35 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Oct 3 21:18:36 2022 +0200

    sw: fix crash in SwParagraphNumTabPage::ExecuteEditNumStyle_Impl
    
    SfxViewShell::Current() could be nullptr
    
    See 
https://crashreport.libreoffice.org/stats/signature/SfxShell::GetDispatcher()
    
    Change-Id: Ic2ffc2a35eff8b8acbb896ece198916ee074b019
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140920
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/ui/chrdlg/numpara.cxx b/sw/source/ui/chrdlg/numpara.cxx
index 8df5c28e5810..fbe38e773eaa 100644
--- a/sw/source/ui/chrdlg/numpara.cxx
+++ b/sw/source/ui/chrdlg/numpara.cxx
@@ -309,10 +309,15 @@ IMPL_LINK_NOARG(SwParagraphNumTabPage, 
EditNumStyleHdl_Impl, weld::Button&, void
 }
 
 // Internal: Perform functions through the Dispatcher
-bool SwParagraphNumTabPage::ExecuteEditNumStyle_Impl(
+void SwParagraphNumTabPage::ExecuteEditNumStyle_Impl(
     sal_uInt16 nId, const OUString &rStr, SfxStyleFamily nFamily)
 {
-    SfxDispatcher &rDispatcher = *SfxViewShell::Current()->GetDispatcher();
+    SfxViewShell* pViewShell = SfxViewShell::Current();
+
+    if( !pViewShell)
+        return;
+
+    SfxDispatcher* pDispatcher = pViewShell->GetDispatcher();
     SfxStringItem aItem(nId, rStr);
     SfxUInt16Item aFamily(SID_STYLE_FAMILY, static_cast<sal_uInt16>(nFamily));
     const SfxPoolItem* pItems[ 3 ];
@@ -331,12 +336,9 @@ bool SwParagraphNumTabPage::ExecuteEditNumStyle_Impl(
     pInternalItems[ 0 ] = &aDialogParent;
     pInternalItems[ 1 ] = nullptr;
 
-    const SfxPoolItem* pItem = rDispatcher.Execute(
+    pDispatcher->Execute(
         nId, SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
         pItems, 0, pInternalItems);
-
-    return pItem != nullptr;
-
 }
 
 IMPL_LINK(SwParagraphNumTabPage, StyleHdl_Impl, weld::ComboBox&, rBox, void)
diff --git a/sw/source/uibase/inc/numpara.hxx b/sw/source/uibase/inc/numpara.hxx
index ca07da56480d..3c34e05d5a49 100644
--- a/sw/source/uibase/inc/numpara.hxx
+++ b/sw/source/uibase/inc/numpara.hxx
@@ -58,7 +58,7 @@ class SwParagraphNumTabPage final : public SfxTabPage
 
     static const WhichRangesContainer s_aPageRg;
 
-    bool ExecuteEditNumStyle_Impl(sal_uInt16 nId, const OUString& rStr,
+    void ExecuteEditNumStyle_Impl(sal_uInt16 nId, const OUString& rStr,
                                   SfxStyleFamily nFamily);
 
 public:

Reply via email to