diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-08-23 21:21:55 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-08-24 10:04:14 +0200 |
commit | a6e5d5d4452dcd612cdfea10d8c2fd99cddebf56 (patch) | |
tree | 4239e80ce6d4bda9fa5373b79bba8639ed8188c3 /cui/source/tabpages | |
parent | 1f5ac5b08fd8c1ddadc5f38595a487db2895957e (diff) |
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@redhat.com>
Diffstat (limited to 'cui/source/tabpages')
-rw-r--r-- | cui/source/tabpages/border.cxx | 58 |
1 files changed, 38 insertions, 20 deletions
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; } |