From 7d746fe50b991a51527aabbadd152ec705c683b3 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 10 Oct 2014 11:28:08 +0100 Subject: coverity#704901 Dereference after null check Change-Id: I6a44577d7520a8faebdf3a6e8de1c91a6e465bac --- sw/source/core/layout/fly.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 9299a2120abd..d0b8975ebda4 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -858,11 +858,19 @@ void SwFlyFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew, } SwFmtURL aURL( GetFmt()->GetURL() ); - if ( aURL.GetMap() ) + + SwFmtFrmSize *pNewFmtFrmSize = NULL; + SwFmtChg *pOldFmtChg = NULL; + if (nWhich == RES_FRM_SIZE) + pNewFmtFrmSize = (SwFmtFrmSize*)pNew; + else + pOldFmtChg = (SwFmtChg*)pOld; + + if (aURL.GetMap() && (pNewFmtFrmSize || pOldFmtChg)) { - const SwFmtFrmSize &rOld = nWhich == RES_FRM_SIZE ? - *(SwFmtFrmSize*)pNew : - ((SwFmtChg*)pOld)->pChangedFmt->GetFrmSize(); + const SwFmtFrmSize &rOld = pNewFmtFrmSize ? + *pNewFmtFrmSize : + pOldFmtChg->pChangedFmt->GetFrmSize(); //#35091# Can be "times zero", when loading the template if ( rOld.GetWidth() && rOld.GetHeight() ) { -- cgit