[Libreoffice-commits] core.git: svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 12 13:41:13 UTC 2021


 svx/source/tbxctrls/fillctrl.cxx |   40 +++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

New commits:
commit 13430459aef6384895b2ab0eec88173f2140a690
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jan 11 10:50:59 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jan 12 14:40:32 2021 +0100

    rhbz#1913070 null deref
    
    its plausible that SfxViewFrame::Current() has returned null, use
    pSh->GetDispatcher() instead protected by null check against pSh
    
    Change-Id: Ibefdcabea09cb3a1a411678585af33a99f8a1c61
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109084
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
index 99cc2401235e..7a6cf136d99d 100644
--- a/svx/source/tbxctrls/fillctrl.cxx
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -686,11 +686,13 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, weld::ComboBox&, void)
             mpLbFillAttr->show();
             mpToolBoxColor->hide();
             mpLbFillAttr->set_sensitive(false);
-
-            // #i122676# need to call a single SID_ATTR_FILL_STYLE change
-            SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
-                SID_ATTR_FILL_STYLE, SfxCallMode::RECORD,
-                { &aXFillStyleItem });
+            if (pSh)
+            {
+                // #i122676# need to call a single SID_ATTR_FILL_STYLE change
+                pSh->GetDispatcher()->ExecuteList(
+                    SID_ATTR_FILL_STYLE, SfxCallMode::RECORD,
+                    { &aXFillStyleItem });
+            }
             break;
         }
         case drawing::FillStyle_SOLID:
@@ -699,11 +701,13 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, weld::ComboBox&, void)
             mpToolBoxColor->show();
             const ::Color aColor = mpColorItem->GetColorValue();
             const XFillColorItem aXFillColorItem( "", aColor );
-
-            // #i122676# change FillStyle and Color in one call
-            SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
-                SID_ATTR_FILL_COLOR, SfxCallMode::RECORD,
-                { &aXFillColorItem, &aXFillStyleItem });
+            if (pSh)
+            {
+                // #i122676# change FillStyle and Color in one call
+                pSh->GetDispatcher()->ExecuteList(
+                    SID_ATTR_FILL_COLOR, SfxCallMode::RECORD,
+                    { &aXFillColorItem, &aXFillStyleItem });
+            }
             break;
         }
         case drawing::FillStyle_GRADIENT:
@@ -730,7 +734,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, weld::ComboBox&, void)
                         const XFillGradientItem aXFillGradientItem(mpLbFillAttr->get_text(mnLastPosGradient), aGradient);
 
                         // #i122676# change FillStyle and Gradient in one call
-                        SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
+                        pSh->GetDispatcher()->ExecuteList(
                             SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD,
                             { &aXFillGradientItem, &aXFillStyleItem });
                         mpLbFillAttr->set_active(mnLastPosGradient);
@@ -767,7 +771,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, weld::ComboBox&, void)
                         const XFillHatchItem aXFillHatchItem(mpLbFillAttr->get_active_text(), aHatch);
 
                         // #i122676# change FillStyle and Hatch in one call
-                        SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
+                        pSh->GetDispatcher()->ExecuteList(
                             SID_ATTR_FILL_HATCH, SfxCallMode::RECORD,
                             { &aXFillHatchItem, &aXFillStyleItem });
                         mpLbFillAttr->set_active(mnLastPosHatch);
@@ -804,7 +808,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, weld::ComboBox&, void)
                         const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->get_active_text(), pXBitmapEntry->GetGraphicObject());
 
                         // #i122676# change FillStyle and Bitmap in one call
-                        SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
+                        pSh->GetDispatcher()->ExecuteList(
                             SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD,
                             { &aXFillBitmapItem, &aXFillStyleItem });
                         mpLbFillAttr->set_active(mnLastPosBitmap);
@@ -838,10 +842,10 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, weld::ComboBox&, void)
     {
         case drawing::FillStyle_SOLID:
         {
-            if(bFillStyleChange)
+            if (bFillStyleChange && pSh)
             {
                 // #i122676# Single FillStyle change call needed here
-                SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
+                pSh->GetDispatcher()->ExecuteList(
                     SID_ATTR_FILL_STYLE, SfxCallMode::RECORD,
                     { &aXFillStyleItem });
             }
@@ -866,7 +870,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, weld::ComboBox&, void)
                     const XFillGradientItem aXFillGradientItem(mpLbFillAttr->get_active_text(), aGradient);
 
                     // #i122676# Change FillStyle and Gradient in one call
-                    SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
+                    pSh->GetDispatcher()->ExecuteList(
                         SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD,
                         bFillStyleChange
                             ? std::initializer_list<SfxPoolItem const*>{ &aXFillGradientItem, &aXFillStyleItem }
@@ -899,7 +903,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, weld::ComboBox&, void)
                     const XFillHatchItem aXFillHatchItem( mpLbFillAttr->get_active_text(), aHatch);
 
                     // #i122676# Change FillStyle and Hatch in one call
-                    SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
+                    pSh->GetDispatcher()->ExecuteList(
                         SID_ATTR_FILL_HATCH, SfxCallMode::RECORD,
                         bFillStyleChange
                             ? std::initializer_list<SfxPoolItem const*>{ &aXFillHatchItem, &aXFillStyleItem }
@@ -932,7 +936,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, weld::ComboBox&, void)
                     const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->get_active_text(), pXBitmapEntry->GetGraphicObject());
 
                     // #i122676# Change FillStyle and Bitmap in one call
-                    SfxViewFrame::Current()->GetDispatcher()->ExecuteList(
+                    pSh->GetDispatcher()->ExecuteList(
                         SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD,
                         bFillStyleChange
                             ? std::initializer_list<SfxPoolItem const*>{ &aXFillBitmapItem, &aXFillStyleItem }


More information about the Libreoffice-commits mailing list