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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 24 08:04:56 UTC 2020


 cui/source/tabpages/border.cxx |   58 ++++++++++++++++++++++++++---------------
 1 file changed, 38 insertions(+), 20 deletions(-)

New commits:
commit a6e5d5d4452dcd612cdfea10d8c2fd99cddebf56
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Aug 23 21:21:55 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Aug 24 10:04:14 2020 +0200

    cid#1466264 Dereference null return value
    
    Change-Id: Idb2543b811cc5081e34ab3d1cc3aaa44399162ab
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101251
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 8dc87e8409bd..d7a58be2f7ef 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -846,32 +846,44 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
 
     if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::TLBR))
     {
-        SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR)));
-        aLineItem.SetLine(m_aFrameSel.GetFrameBorderStyle(svx::FrameBorderType::TLBR));
-        rCoreAttrs->Put(aLineItem);
-        bAttrsChanged = true;
+        if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR))
+        {
+            SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(pOldItem));
+            aLineItem.SetLine(m_aFrameSel.GetFrameBorderStyle(svx::FrameBorderType::TLBR));
+            rCoreAttrs->Put(aLineItem);
+            bAttrsChanged = true;
+        }
     }
 
     if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::BLTR))
     {
-        SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR)));
-        aLineItem.SetLine(m_aFrameSel.GetFrameBorderStyle(svx::FrameBorderType::BLTR));
-        rCoreAttrs->Put(aLineItem);
-        bAttrsChanged = true;
+        if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR))
+        {
+            SvxLineItem aLineItem(*static_cast<const SvxLineItem*>(pOldItem));
+            aLineItem.SetLine(m_aFrameSel.GetFrameBorderStyle(svx::FrameBorderType::BLTR));
+            rCoreAttrs->Put(aLineItem);
+            bAttrsChanged = true;
+        }
     }
 
     if (m_xShadowControls && m_xShadowControls->get_value_changed_from_saved())
     {
-        const SvxShadowItem& rOldShadowItem = *static_cast<const SvxShadowItem*>(GetOldItem(*rCoreAttrs, mnShadowSlot));
-        rCoreAttrs->Put(m_xShadowControls->GetControlValue(rOldShadowItem));
-        bAttrsChanged = true;
+        if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, mnShadowSlot))
+        {
+            const SvxShadowItem& rOldShadowItem = *static_cast<const SvxShadowItem*>(pOldItem);
+            rCoreAttrs->Put(m_xShadowControls->GetControlValue(rOldShadowItem));
+            bAttrsChanged = true;
+        }
     }
 
     if (m_xMarginControls && m_xMarginControls->get_value_changed_from_saved())
     {
-        const SvxMarginItem& rOldMarginItem = *static_cast<const SvxMarginItem*>(GetOldItem(*rCoreAttrs, SID_ATTR_ALIGN_MARGIN));
-        rCoreAttrs->Put(m_xMarginControls->GetControlValue(rOldMarginItem));
-        bAttrsChanged = true;
+        if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_ALIGN_MARGIN))
+        {
+            const SvxMarginItem& rOldMarginItem = *static_cast<const SvxMarginItem*>(pOldItem);
+            rCoreAttrs->Put(m_xMarginControls->GetControlValue(rOldMarginItem));
+            bAttrsChanged = true;
+        }
     }
 
     if (m_xMergeAdjacentBordersCB->get_state_changed_from_saved())
@@ -884,9 +896,12 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
         }
         else
         {
-            std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(GetOldItem(*rCoreAttrs, SID_SW_COLLAPSING_BORDERS)->Clone()));
-            xNewItem->SetValue(static_cast<bool>(nState));
-            rCoreAttrs->Put(std::move(xNewItem));
+            if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_SW_COLLAPSING_BORDERS))
+            {
+                std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
+                xNewItem->SetValue(static_cast<bool>(nState));
+                rCoreAttrs->Put(std::move(xNewItem));
+            }
         }
         bAttrsChanged = true;
     }
@@ -901,9 +916,12 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
         }
         else
         {
-            std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_CONNECT)->Clone()));
-            xNewItem->SetValue(static_cast<bool>(nState));
-            rCoreAttrs->Put(std::move(xNewItem));
+            if (const SfxPoolItem* pOldItem = GetOldItem(*rCoreAttrs, SID_ATTR_BORDER_CONNECT))
+            {
+                std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
+                xNewItem->SetValue(static_cast<bool>(nState));
+                rCoreAttrs->Put(std::move(xNewItem));
+            }
         }
         bAttrsChanged = true;
     }


More information about the Libreoffice-commits mailing list