[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 12 10:14:34 UTC 2021


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

New commits:
commit ec542cd17d376b0cfabc0a5cf82edd1fd3012350
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jan 11 10:50:59 2021 +0000
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Tue Jan 12 11:13:58 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/+/109003
    Tested-by: Michael Stahl <michael.stahl at allotropia.de>
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>

diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
index d0301b5d3b8c..788a8fe1c1a1 100644
--- a/svx/source/tbxctrls/fillctrl.cxx
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -687,11 +687,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:
@@ -700,11 +702,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:
@@ -731,7 +735,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);
@@ -768,7 +772,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);
@@ -805,7 +809,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);
@@ -839,10 +843,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 });
             }
@@ -867,7 +871,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 }
@@ -900,7 +904,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 }
@@ -933,7 +937,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