From 5718c72ae89fb1a7aa8ee292dc9cb92acbde92db Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 17 Oct 2015 15:08:35 +0100 Subject: afl-eventtesting: first discovered impress crash via event fuzzing SfxObjectShell::Current can and does return null sometimes protect this init like the other sidebar example and add missing licence header Change-Id: I15d40c08e8ac37116de7d543c16257c8a8090e8a --- svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 8 ++--- svx/source/sidebar/shadow/ShadowPropertyPanel.cxx | 43 +++++++++++++++-------- svx/source/sidebar/shadow/ShadowPropertyPanel.hxx | 10 +++++- 3 files changed, 41 insertions(+), 20 deletions(-) (limited to 'svx') diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx index 4b5b127fe11a..ee40b27472f9 100644 --- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx @@ -254,9 +254,9 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) mpMTRAngle->Show(); mpToolBoxColor->Hide(); - if(pSh && pSh->GetItem(SID_COLOR_TABLE)) + const SvxColorListItem* pColorListItem = static_cast(pSh ? pSh->GetItem(SID_COLOR_TABLE) : nullptr); + if (pColorListItem) { - const SvxColorListItem aColorListItem(*static_cast(pSh->GetItem(SID_COLOR_TABLE))); mpLbFillAttr->Enable(); mpLbFillGradTo->Enable(); mpLbFillGradFrom->Enable(); @@ -265,8 +265,8 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox&, void) mpLbFillAttr->Clear(); mpLbFillGradTo->Clear(); mpLbFillGradFrom->Clear(); - mpLbFillGradTo->Fill(aColorListItem.GetColorList()); - mpLbFillGradFrom->Fill(aColorListItem.GetColorList()); + mpLbFillGradTo->Fill(pColorListItem->GetColorList()); + mpLbFillGradFrom->Fill(pColorListItem->GetColorList()); mpLbFillGradFrom->AdaptDropDownLineCountToMaximum(); mpLbFillGradTo->AdaptDropDownLineCountToMaximum(); diff --git a/svx/source/sidebar/shadow/ShadowPropertyPanel.cxx b/svx/source/sidebar/shadow/ShadowPropertyPanel.cxx index 36dfb519b9e2..cbb62ade9e93 100644 --- a/svx/source/sidebar/shadow/ShadowPropertyPanel.cxx +++ b/svx/source/sidebar/shadow/ShadowPropertyPanel.cxx @@ -1,3 +1,11 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ #include #include #include @@ -118,21 +126,24 @@ void ShadowPropertyPanel::dispose() void ShadowPropertyPanel::Initialize() { - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - const SfxPoolItem* pItem = pDocSh->GetItem(SID_COLOR_TABLE); - pColorList = static_cast(pItem) ->GetColorList(); - mpLBShadowColor->Fill(pColorList); - mpShowShadow->SetState( TRISTATE_FALSE ); - mpShowShadow->SetClickHdl( LINK(this, ShadowPropertyPanel, ClickShadowHdl ) ); - mpShadowTransMetric->SetModifyHdl( LINK(this, ShadowPropertyPanel, ModifyShadowTransMetricHdl) ); - mpLBShadowColor->SetSelectHdl( LINK( this, ShadowPropertyPanel, ModifyShadowColorHdl ) ); - mpShadowAngle->SetModifyHdl( LINK(this, ShadowPropertyPanel, ModifyShadowDistanceHdl) ); - mpShadowDistance->SetModifyHdl( LINK(this, ShadowPropertyPanel, ModifyShadowDistanceHdl) ); - mpShadowTransSlider->SetRange(Range(0,100)); - mpShadowTransSlider->SetUpdateMode(true); - mpShadowTransSlider->SetSlideHdl( LINK(this, ShadowPropertyPanel, ModifyShadowTransSliderHdl) ); - InsertDistanceValues(); - InsertAngleValues(); + SfxObjectShell* pSh = SfxObjectShell::Current(); + + const SvxColorListItem* pColorListItem = static_cast(pSh ? pSh->GetItem(SID_COLOR_TABLE) : nullptr); + if (pColorListItem) + { + mpLBShadowColor->Fill(pColorListItem->GetColorList()); + mpShowShadow->SetState( TRISTATE_FALSE ); + mpShowShadow->SetClickHdl( LINK(this, ShadowPropertyPanel, ClickShadowHdl ) ); + mpShadowTransMetric->SetModifyHdl( LINK(this, ShadowPropertyPanel, ModifyShadowTransMetricHdl) ); + mpLBShadowColor->SetSelectHdl( LINK( this, ShadowPropertyPanel, ModifyShadowColorHdl ) ); + mpShadowAngle->SetModifyHdl( LINK(this, ShadowPropertyPanel, ModifyShadowDistanceHdl) ); + mpShadowDistance->SetModifyHdl( LINK(this, ShadowPropertyPanel, ModifyShadowDistanceHdl) ); + mpShadowTransSlider->SetRange(Range(0,100)); + mpShadowTransSlider->SetUpdateMode(true); + mpShadowTransSlider->SetSlideHdl( LINK(this, ShadowPropertyPanel, ModifyShadowTransSliderHdl) ); + InsertDistanceValues(); + InsertAngleValues(); + } } IMPL_LINK_NOARG_TYPED(ShadowPropertyPanel, ClickShadowHdl, Button*, void) @@ -362,3 +373,5 @@ VclPtr ShadowPropertyPanel::Create ( } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/shadow/ShadowPropertyPanel.hxx b/svx/source/sidebar/shadow/ShadowPropertyPanel.hxx index 689a9bdfb95b..6b28a252bbe2 100644 --- a/svx/source/sidebar/shadow/ShadowPropertyPanel.hxx +++ b/svx/source/sidebar/shadow/ShadowPropertyPanel.hxx @@ -1,3 +1,11 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ #ifndef INCLUDED_SVX_SOURCE_SIDEBAR_AREA_SHADOWPROPERTYPANEL_HXX #define INCLUDED_SVX_SOURCE_SIDEBAR_AREA_SHADOWPROPERTYPANEL_HXX @@ -63,7 +71,6 @@ private: VclPtr mpFTColor; VclPtr mpShadowTransSlider; VclPtr mpShadowTransMetric; - XColorListRef pColorList; ::sfx2::sidebar::ControllerItem maShadowController; ::sfx2::sidebar::ControllerItem maShadowTransController; @@ -91,3 +98,4 @@ private: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit