sfx2/source/sidebar/SidebarDockingWindow.cxx |  117 +++++++++++++--------------
 1 file changed, 60 insertions(+), 57 deletions(-)

New commits:
commit d4d923f9db926d8b0b6eb3bb7b62f5a7a520c00d
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Mar 28 11:23:56 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Mar 28 15:53:08 2024 +0100

    null deref of mpSidebarController
    
    follow the pattern used in the rest of this and skip the branch
    that depends on mpSidebarController existing
    
    git show -w
    
    Change-Id: I739754b2af7ad09fa80c36693d8adbf173ece2e2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165426
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx 
b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 23c3b459c3be..d0edf8066332 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -136,75 +136,78 @@ SfxChildAlignment SidebarDockingWindow::CheckAlignment (
 
 bool SidebarDockingWindow::EventNotify(NotifyEvent& rEvent)
 {
-    NotifyEventType nType = rEvent.GetType();
-    if (NotifyEventType::KEYINPUT == nType)
+    if (mpSidebarController)
     {
-        const vcl::KeyCode& rKeyCode = rEvent.GetKeyEvent()->GetKeyCode();
-        switch (rKeyCode.GetCode())
+        NotifyEventType nType = rEvent.GetType();
+        if (NotifyEventType::KEYINPUT == nType)
         {
-            case KEY_UP:
-            case KEY_DOWN:
-            case KEY_PAGEUP:
-            case KEY_PAGEDOWN:
-            case KEY_HOME:
-            case KEY_END:
-            case KEY_LEFT:
-            case KEY_RIGHT:
-            case KEY_BACKSPACE:
-            case KEY_DELETE:
-            case KEY_INSERT:
-            case KEY_RETURN:
-            case KEY_ESCAPE:
+            const vcl::KeyCode& rKeyCode = rEvent.GetKeyEvent()->GetKeyCode();
+            switch (rKeyCode.GetCode())
             {
+                case KEY_UP:
+                case KEY_DOWN:
+                case KEY_PAGEUP:
+                case KEY_PAGEDOWN:
+                case KEY_HOME:
+                case KEY_END:
+                case KEY_LEFT:
+                case KEY_RIGHT:
+                case KEY_BACKSPACE:
+                case KEY_DELETE:
+                case KEY_INSERT:
+                case KEY_RETURN:
+                case KEY_ESCAPE:
+                {
+                    return true;
+                }
+                default:
+                break;
+            }
+            if (!mpAccel)
+            {
+                mpAccel = svt::AcceleratorExecute::createAcceleratorHelper();
+                mpAccel->init(comphelper::getProcessComponentContext(), 
mpSidebarController->getXFrame());
+            }
+            const OUString 
aCommand(mpAccel->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rKeyCode)));
+            if (".uno:DesignerDialog" == aCommand)
+            {
+                std::shared_ptr<PanelDescriptor> xPanelDescriptor =
+                        
mpSidebarController->GetResourceManager()->GetPanelDescriptor( 
u"StyleListPanel" );
+                if ( xPanelDescriptor && mpSidebarController->IsDeckVisible( 
xPanelDescriptor->msDeckId ) )
+                    Close();
+                return true;
+            }
+            if (".uno:Undo" == aCommand || ".uno:Redo" == aCommand)
+            {
+                comphelper::dispatchCommand(aCommand, {});
                 return true;
             }
-            default:
-            break;
-        }
-        if (!mpAccel)
-        {
-            mpAccel = svt::AcceleratorExecute::createAcceleratorHelper();
-            mpAccel->init(comphelper::getProcessComponentContext(), 
mpSidebarController->getXFrame());
-        }
-        const OUString 
aCommand(mpAccel->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rKeyCode)));
-        if (".uno:DesignerDialog" == aCommand)
-        {
-            std::shared_ptr<PanelDescriptor> xPanelDescriptor =
-                    
mpSidebarController->GetResourceManager()->GetPanelDescriptor( 
u"StyleListPanel" );
-            if ( xPanelDescriptor && mpSidebarController->IsDeckVisible( 
xPanelDescriptor->msDeckId ) )
-                Close();
-            return true;
         }
-        if (".uno:Undo" == aCommand || ".uno:Redo" == aCommand)
+        else if (NotifyEventType::MOUSEBUTTONDOWN == nType)
         {
-            comphelper::dispatchCommand(aCommand, {});
-            return true;
+            const MouseEvent *mEvt = rEvent.GetMouseEvent();
+            if (mEvt->IsLeft())
+            {
+                tools::Rectangle aGrip = 
mpSidebarController->GetDeckDragArea();
+                if ( aGrip.Contains( mEvt->GetPosPixel() ) )
+                    mbIsReadyToDrag = true;
+            }
         }
-    }
-    else if (NotifyEventType::MOUSEBUTTONDOWN == nType)
-    {
-        const MouseEvent *mEvt = rEvent.GetMouseEvent();
-        if (mEvt->IsLeft())
+        else if (NotifyEventType::MOUSEMOVE == nType)
         {
+            const MouseEvent *mEvt = rEvent.GetMouseEvent();
             tools::Rectangle aGrip = mpSidebarController->GetDeckDragArea();
-            if ( aGrip.Contains( mEvt->GetPosPixel() ) )
-                mbIsReadyToDrag = true;
-        }
-    }
-    else if (NotifyEventType::MOUSEMOVE == nType)
-    {
-        const MouseEvent *mEvt = rEvent.GetMouseEvent();
-        tools::Rectangle aGrip = mpSidebarController->GetDeckDragArea();
-        if (mEvt->IsLeft() && aGrip.Contains( mEvt->GetPosPixel() ) && 
mbIsReadyToDrag )
-        {
-            Point aPos = mEvt->GetPosPixel();
-            vcl::Window* pWindow = rEvent.GetWindow();
-            if ( pWindow != this )
+            if (mEvt->IsLeft() && aGrip.Contains( mEvt->GetPosPixel() ) && 
mbIsReadyToDrag )
             {
-                aPos = pWindow->OutputToScreenPixel( aPos );
-                aPos = ScreenToOutputPixel( aPos );
+                Point aPos = mEvt->GetPosPixel();
+                vcl::Window* pWindow = rEvent.GetWindow();
+                if ( pWindow != this )
+                {
+                    aPos = pWindow->OutputToScreenPixel( aPos );
+                    aPos = ScreenToOutputPixel( aPos );
+                }
+                ImplStartDocking( aPos );
             }
-            ImplStartDocking( aPos );
         }
     }
 

Reply via email to