include/sfx2/dispatch.hxx        |    4 ++--
 sfx2/source/control/bindings.cxx |    3 +++
 sfx2/source/control/dispatch.cxx |   16 +++++++++-------
 sfx2/source/view/viewfrm.cxx     |    4 ++--
 4 files changed, 16 insertions(+), 11 deletions(-)

New commits:
commit 6715899547fd8960e236b090d44367eafef3eb71
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue May 21 18:36:48 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu May 23 09:36:42 2024 +0200

    sfx2: use SAL_RET_MAYBENULL in GetBindings() and GetShell()
    
    after 9eb083ab732512c3ab64007c3be1c54be97172f6
    "check GetShell"
    
    Change-Id: I0dcef57019fde7639ddbb981cbd41c13f857b4af
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167905
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index 48cb3605a8c0..17d2fa464e3b 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -132,12 +132,12 @@ public:
 
     bool                IsActive( const SfxShell& rShell );
     sal_uInt16          GetShellLevel( const SfxShell &rShell );
-    SfxBindings*        GetBindings() const;
+    SAL_RET_MAYBENULL SfxBindings* GetBindings() const;
 
     void                Push( SfxShell& rShell );
     void                Pop( SfxShell& rShell, SfxDispatcherPopFlags nMode = 
SfxDispatcherPopFlags::NONE );
 
-    SfxShell*           GetShell(sal_uInt16 nIdx) const;
+    SAL_RET_MAYBENULL SfxShell* GetShell(sal_uInt16 nIdx) const;
     SfxViewFrame*       GetFrame() const;
     SfxModule*          GetModule() const;
 
commit 50fa7d2581a69ffec4da6e3cce6a6f0e514b7aa5
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed May 22 10:17:20 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu May 23 09:36:33 2024 +0200

    sfx2: warning C6011: Dereferencing NULL pointer
    
    Change-Id: Ie65284c3ded0c5789f0be5bbd770d190a92fecec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167922
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 659d72254868..ffafadfeb2a6 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -944,6 +944,9 @@ SfxPoolItemHolder SfxBindings::Execute_Impl( sal_uInt16 
nId, const SfxPoolItem**
         pSlot = pServer->GetSlot();
     }
 
+    if (!pShell)
+        return SfxPoolItemHolder();
+
     SfxItemPool &rPool = pShell->GetPool();
     SfxRequest aReq( nId, nCallMode, rPool );
     aReq.SetModifier( nModi );
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index d16a099b9578..d0ebae89f73d 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -707,7 +707,7 @@ bool SfxDispatcher::GetShellAndSlot_Impl(sal_uInt16 nSlot, 
SfxShell** ppShell,
 
         *ppShell = GetShell(aSvr.GetShellLevel());
         *ppSlot = aSvr.GetSlot();
-        if ( nullptr == (*ppSlot)->GetExecFnc() && bRealSlot )
+        if ( nullptr == (*ppSlot)->GetExecFnc() && bRealSlot && *ppShell )
             *ppSlot = (*ppShell)->GetInterface()->GetRealSlot(*ppSlot);
         // Check only real slots as enum slots don't have an execute function!
         return !bRealSlot || ((nullptr != *ppSlot) && (nullptr != 
(*ppSlot)->GetExecFnc()) );
@@ -985,13 +985,15 @@ void 
SfxDispatcher::PostMsgHandler(std::unique_ptr<SfxRequest> pReq)
         SfxSlotServer aSvr;
         if ( FindServer_(pReq->GetSlot(), aSvr ) ) // HACK(x), whatever that 
was supposed to mean
         {
-            const SfxSlot *pSlot = aSvr.GetSlot();
-            SfxShell *pSh = GetShell(aSvr.GetShellLevel());
+            if (SfxShell *pSh = GetShell(aSvr.GetShellLevel()))
+            {
+                const SfxSlot *pSlot = aSvr.GetSlot();
 
-            // When the pSlot is a "Pseudoslot" for macros or Verbs, it can
-            // be destroyed in the Call_Impl, thus do not use it anymore!
-            pReq->SetSynchronCall( false );
-            Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() ); //! why 
bRecord?
+                // When the pSlot is a "Pseudoslot" for macros or Verbs, it can
+                // be destroyed in the Call_Impl, thus do not use it anymore!
+                pReq->SetSynchronCall( false );
+                Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() ); //! 
why bRecord?
+            }
         }
     }
     else
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index c79d766676e8..cb93b9c000de 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1094,8 +1094,8 @@ void SfxViewFrame::PopShellAndSubShells_Impl( 
SfxViewShell& i_rViewShell )
         if ( nLevel )
         {
             // more sub shells on the stack, which were not affected by 
PopSubShells_Impl
-            SfxShell *pSubShell = m_pDispatcher->GetShell( nLevel-1 );
-            m_pDispatcher->Pop( *pSubShell, SfxDispatcherPopFlags::POP_UNTIL | 
SfxDispatcherPopFlags::POP_DELETE );
+            if (SfxShell *pSubShell = m_pDispatcher->GetShell( nLevel-1 ))
+                m_pDispatcher->Pop( *pSubShell, 
SfxDispatcherPopFlags::POP_UNTIL | SfxDispatcherPopFlags::POP_DELETE );
         }
         m_pDispatcher->Pop( i_rViewShell );
         m_pDispatcher->Flush();

Reply via email to