From bcb1f81668d9b6a6d807ae32d60ccfce0b36ceb5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 15 Jul 2015 18:38:38 +0200 Subject: svx, sd, sw: GetPoolDefaultItem() can actually return nullptr ...if you call ResetPoolDefaultItem() first. Crash found by Varun Dhall. Change-Id: I409484c172fb5843270aee2425844076a008b4df --- sd/source/core/stlpool.cxx | 5 ++++- svx/source/unodraw/unopool.cxx | 5 ++++- sw/source/core/unocore/SwXTextDefaults.cxx | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index f4eee3948da8..a45bbaa706ed 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -1127,7 +1127,10 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet, case HID_PSEUDOSHEET_SUBTITLE : { // Subtitle template - SvxNumRule* pDefaultRule = static_cast( rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET))->GetNumRule(); + SvxNumBulletItem const*const pItem( + static_cast( + rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET))); + SvxNumRule *const pDefaultRule = (pItem) ? pItem->GetNumRule() : nullptr; DBG_ASSERT( pDefaultRule, "Where is my default template? [CL]" ); if(pDefaultRule) diff --git a/svx/source/unodraw/unopool.cxx b/svx/source/unodraw/unopool.cxx index bc4f253e55f5..dccdbaded4b8 100644 --- a/svx/source/unodraw/unopool.cxx +++ b/svx/source/unodraw/unopool.cxx @@ -321,7 +321,10 @@ uno::Any SvxUnoDrawPool::_getPropertyDefault( const comphelper::PropertyMapEntry SfxItemPool* pPool = getModelPool( true ); const sal_uInt16 nWhich = pPool->GetWhich( (sal_uInt16)pEntry->mnHandle ); const SfxPoolItem *pItem = pPool->GetPoolDefaultItem ( nWhich ); - pItem->QueryValue( aAny, pEntry->mnMemberId ); + if (pItem) + { + pItem->QueryValue( aAny, pEntry->mnMemberId ); + } return aAny; } diff --git a/sw/source/core/unocore/SwXTextDefaults.cxx b/sw/source/core/unocore/SwXTextDefaults.cxx index 9955b4417c59..5c6e25683098 100644 --- a/sw/source/core/unocore/SwXTextDefaults.cxx +++ b/sw/source/core/unocore/SwXTextDefaults.cxx @@ -219,8 +219,11 @@ Any SAL_CALL SwXTextDefaults::getPropertyDefault( const OUString& rPropertyName throw UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); Any aRet; SfxItemPool& rSet (m_pDoc->GetAttrPool()); - const SfxPoolItem *pItem = rSet.GetPoolDefaultItem ( pMap->nWID ); - pItem->QueryValue( aRet, pMap->nMemberId ); + SfxPoolItem const*const pItem = rSet.GetPoolDefaultItem(pMap->nWID); + if (pItem) + { + pItem->QueryValue( aRet, pMap->nMemberId ); + } return aRet; } -- cgit