Avoid premature downcast

With 98cc40cc57 "ubsan: fix downcast",
CppunitTest_sc_vba_macro_test had started to occasionally fail for me with

> svx/source/sidebar/area/AreaPropertyPanelBase.cxx:1091:62: runtime error: downcast of address 0x7b0316a41b20 which does not point to an object of type 'const XFillTransparenceItem'
> 0x7b0316a41b20: note: object is of type '(anonymous namespace)::InvalidItem'
>  00 00 00 00  10 a4 5b 16 03 7b 00 00  00 00 00 00 00 00 00 00  00 00 00 00 09 00 00 00  00 00 00 00
>               ^~~~~~~~~~~~~~~~~~~~~~~
>               vptr for '(anonymous namespace)::InvalidItem'
>  #0 in svx::sidebar::AreaPropertyPanelBase::NotifyItemUpdate(unsigned short, SfxItemState, SfxPoolItem const*) at svx/source/sidebar/area/AreaPropertyPanelBase.cxx:1091:62
>  #1 in sfx2::sidebar::ControllerItem::ReceiverNotifyItemUpdate(unsigned short, SfxItemState, SfxPoolItem const*) at sfx2/source/sidebar/ControllerItem.cxx:65:26
>  #2 in sfx2::sidebar::ControllerItem::StateChangedAtToolBoxControl(unsigned short, SfxItemState, SfxPoolItem const*) at sfx2/source/sidebar/ControllerItem.cxx:73:5
>  #3 in SfxStateCache::SetState_Impl(SfxItemState, SfxPoolItem const*, bool) at sfx2/source/control/statcach.cxx:428:24
>  #4 in SfxStateCache::SetState(SfxItemState, SfxPoolItem const*, bool) at sfx2/source/control/statcach.cxx:335:5
>  #5 in SfxBindings::UpdateControllers_Impl(SfxFoundCache_Impl const&, SfxPoolItem const*, SfxItemState) at sfx2/source/control/bindings.cxx:1188:16
>  #6 in SfxBindings::Update_Impl(SfxStateCache&) at sfx2/source/control/bindings.cxx:278:17
>  #7 in SfxBindings::NextJob_Impl(Timer const*) at sfx2/source/control/bindings.cxx:1264:17
>  #8 in SfxBindings::NextJob(Timer*) at sfx2/source/control/bindings.cxx:1209:5
>  #9 in SfxBindings::LinkStubNextJob(void*, Timer*) at sfx2/source/control/bindings.cxx:1204:25
>  #10 in Link<Timer*, void>::Call(Timer*) const at include/tools/link.hxx:105:45
>  #11 in Timer::Invoke() at vcl/source/app/timer.cxx:75:21
>  #12 in Scheduler::CallbackTaskScheduling() at vcl/source/app/scheduler.cxx:615:20
>  #13 in SalTimer::CallCallback() at vcl/inc/saltimer.hxx:53:13
>  #14 in SvpSalInstance::CheckTimeout(bool) at vcl/headless/svpinst.cxx:171:53
>  #15 in SvpSalInstance::ImplYield(bool, bool) at vcl/headless/svpinst.cxx:447:17
>  #16 in SvpSalInstance::DoYield(bool, bool) at vcl/headless/svpinst.cxx:519:21
>  #17 in InnerYield(bool, bool) at vcl/source/app/svapp.cxx:389:48
>  #18 in Application::Reschedule(bool) at vcl/source/app/svapp.cxx:415:17
>  #19 in SbiRuntime::Step() at basic/source/runtime/runtime.cxx:775:17
>  #20 in (anonymous namespace)::RunInitGuard::run() at basic/source/classes/sbxmod.cxx:1029:27
>  #21 in SbModule::Run(SbMethod*) at basic/source/classes/sbxmod.cxx:1189:31
>  #22 in SbModule::Notify(SfxBroadcaster&, SfxHint const&) at basic/source/classes/sbxmod.cxx:783:17
>  #23 in SfxBroadcaster::Broadcast(SfxHint const&) at svl/source/notify/SfxBroadcaster.cxx:43:24
>  #24 in SbMethod::Broadcast(SfxHintId) at basic/source/classes/sbxmod.cxx:2124:20
>  #25 in SbxValue::SbxValue(SbxValue const&) at basic/source/sbx/sbxvalue.cxx:67:36
>  #26 in SbxVariable::SbxVariable(SbxVariable const&) at basic/source/sbx/sbxvar.cxx:48:7
>  #27 in SbxMethod::SbxMethod(SbxMethod const&) at basic/source/sbx/sbxobj.cxx:841:7
>  #28 in SbiRuntime::FindElement(SbxObject*, unsigned int, unsigned int, ErrCode, bool, bool) at basic/source/runtime/runtime.cxx:3700:37
>  #29 in SbiRuntime::StepFIND_Impl(SbxObject*, unsigned int, unsigned int, ErrCode, bool) at basic/source/runtime/runtime.cxx:4142:14
>  #30 in SbiRuntime::StepFIND(unsigned int, unsigned int) at basic/source/runtime/runtime.cxx:4148:5
>  #31 in SbiRuntime::Step() at basic/source/runtime/runtime.cxx:805:13
>  #32 in (anonymous namespace)::RunInitGuard::run() at basic/source/classes/sbxmod.cxx:1029:27
>  #33 in SbModule::Run(SbMethod*) at basic/source/classes/sbxmod.cxx:1189:31
>  #34 in SbModule::Notify(SfxBroadcaster&, SfxHint const&) at basic/source/classes/sbxmod.cxx:783:17
>  #35 in SfxBroadcaster::Broadcast(SfxHint const&) at svl/source/notify/SfxBroadcaster.cxx:43:24
>  #36 in SbMethod::Broadcast(SfxHintId) at basic/source/classes/sbxmod.cxx:2124:20
>  #37 in SbxValue::SbxValue(SbxValue const&) at basic/source/sbx/sbxvalue.cxx:67:36
>  #38 in SbxVariable::SbxVariable(SbxVariable const&) at basic/source/sbx/sbxvar.cxx:48:7
>  #39 in SbxMethod::SbxMethod(SbxMethod const&) at basic/source/sbx/sbxobj.cxx:841:7
>  #40 in SbiRuntime::FindElement(SbxObject*, unsigned int, unsigned int, ErrCode, bool, bool) at basic/source/runtime/runtime.cxx:3700:37
>  #41 in SbiRuntime::StepFIND_Impl(SbxObject*, unsigned int, unsigned int, ErrCode, bool) at basic/source/runtime/runtime.cxx:4142:14
>  #42 in SbiRuntime::StepFIND(unsigned int, unsigned int) at basic/source/runtime/runtime.cxx:4148:5
>  #43 in SbiRuntime::Step() at basic/source/runtime/runtime.cxx:805:13
>  #44 in (anonymous namespace)::RunInitGuard::run() at basic/source/classes/sbxmod.cxx:1029:27
>  #45 in SbModule::Run(SbMethod*) at basic/source/classes/sbxmod.cxx:1189:31
>  #46 in SbModule::Notify(SfxBroadcaster&, SfxHint const&) at basic/source/classes/sbxmod.cxx:783:17
>  #47 in SfxBroadcaster::Broadcast(SfxHint const&) at svl/source/notify/SfxBroadcaster.cxx:43:24
>  #48 in SbMethod::Broadcast(SfxHintId) at basic/source/classes/sbxmod.cxx:2124:20
>  #49 in SbxValue::Get(SbxValues&) const at basic/source/sbx/sbxvalue.cxx:289:16
>  #50 in SbMethod::Call(SbxValue*, SbxVariable*) at basic/source/classes/sbxmod.cxx:2080:5
>  #51 in basprov::BasicScriptImpl::invoke(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, com::sun::star::uno::Sequence<short>&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) at scripting/source/basprov/basscript.cxx:262:35
>  #52 in non-virtual thunk to basprov::BasicScriptImpl::invoke(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, com::sun::star::uno::Sequence<short>&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&) at scripting/source/basprov/basscript.cxx
>  #53 in SfxObjectShell::CallXScript(com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, com::sun::star::uno::Any&, com::sun::star::uno::Sequence<short>&, com::sun::star::uno::Sequence<com::sun::star::uno::Any>&, bool, com::sun::star::uno::Any const*) at sfx2/source/doc/objmisc.cxx:1557:25
>  #54 in UnoApiTest::executeMacro(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) at test/source/unoapi_test.cxx:341:22
>  #55 in testVba::TestBody() at sc/qa/extras/vba-macro-test.cxx:425:25

Change-Id: Ic99db107d01400ceb4783915b361133399ec39d2
Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/35
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit fe8240112db49c6713bccc15c4cc6d4f77f19648)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205207
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
This commit is contained in:
Stephan Bergmann
2026-05-15 08:32:02 +02:00
committed by Julien Nabet
parent 79d17e9944
commit 5f76dc0194
@@ -1103,7 +1103,7 @@ void AreaPropertyPanelBase::NotifyItemUpdate(
switch(nSID)
{
case SID_ATTR_FILL_TRANSPARENCE:
updateFillTransparence(bDisabled, bDefaultOrSet, static_cast<const XFillTransparenceItem*>(pState));
updateFillTransparence(bDisabled, bDefaultOrSet, bDefaultOrSet ? static_cast<const XFillTransparenceItem*>(pState) : nullptr);
break;
case SID_ATTR_FILL_FLOATTRANSPARENCE:
updateFillFloatTransparence(bDisabled, bDefaultOrSet, pState);