diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-03-15 12:49:57 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-03-15 20:55:47 +0000 |
commit | 64f41f1ae17e47e78175083bad3a3165fbf2053f (patch) | |
tree | 92a05e075354998bf0765579bbfd197b752caf1c | |
parent | 2041a2ee84dd7298e6d8a930d714686d4e7ac61b (diff) |
coverity#704908 Dereference after null check
Change-Id: I74addce71d6044da27d9021dc3aef0c73dd55d27
-rw-r--r-- | sw/source/core/layout/pagechg.cxx | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index b809700a6f52..1a976615c6e5 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -549,34 +549,36 @@ void SwPageFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew, { // If the frame format is changed, several things might also change: // 1. columns: - OSL_ENSURE( pOld && pNew, "FMT_CHG Missing Format." ); - const SwFmt* pOldFmt = ((SwFmtChg*)pOld)->pChangedFmt; - const SwFmt* pNewFmt = ((SwFmtChg*)pNew)->pChangedFmt; - OSL_ENSURE( pOldFmt && pNewFmt, "FMT_CHG Missing Format." ); - - const SwFmtCol &rOldCol = pOldFmt->GetCol(); - const SwFmtCol &rNewCol = pNewFmt->GetCol(); - if( rOldCol != rNewCol ) + assert(pOld && pNew); //FMT_CHG Missing Format + const SwFmt* pOldFmt = pOld ? ((SwFmtChg*)pOld)->pChangedFmt : NULL; + const SwFmt* pNewFmt = pNew ? ((SwFmtChg*)pNew)->pChangedFmt : NULL; + assert(pOldFmt && pNewFmt); //FMT_CHG Missing Format + if (pOldFmt && pNewFmt) { - SwLayoutFrm *pB = FindBodyCont(); - OSL_ENSURE( pB, "Seite ohne Body." ); - pB->ChgColumns( rOldCol, rNewCol ); - rInvFlags |= 0x20; - } - - // 2. header and footer: - const SwFmtHeader &rOldH = pOldFmt->GetHeader(); - const SwFmtHeader &rNewH = pNewFmt->GetHeader(); - if( rOldH != rNewH ) - rInvFlags |= 0x08; + const SwFmtCol &rOldCol = pOldFmt->GetCol(); + const SwFmtCol &rNewCol = pNewFmt->GetCol(); + if( rOldCol != rNewCol ) + { + SwLayoutFrm *pB = FindBodyCont(); + OSL_ENSURE( pB, "Seite ohne Body." ); + pB->ChgColumns( rOldCol, rNewCol ); + rInvFlags |= 0x20; + } - const SwFmtFooter &rOldF = pOldFmt->GetFooter(); - const SwFmtFooter &rNewF = pNewFmt->GetFooter(); - if( rOldF != rNewF ) - rInvFlags |= 0x10; - CheckDirChange(); + // 2. header and footer: + const SwFmtHeader &rOldH = pOldFmt->GetHeader(); + const SwFmtHeader &rNewH = pNewFmt->GetHeader(); + if( rOldH != rNewH ) + rInvFlags |= 0x08; + + const SwFmtFooter &rOldF = pOldFmt->GetFooter(); + const SwFmtFooter &rNewF = pNewFmt->GetFooter(); + if( rOldF != rNewF ) + rInvFlags |= 0x10; + CheckDirChange(); + } } - // no break + // no break case RES_FRM_SIZE: { const SwRect aOldPageFrmRect( Frm() ); @@ -625,12 +627,14 @@ void SwPageFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew, break; case RES_COL: - { - SwLayoutFrm *pB = FindBodyCont(); - OSL_ENSURE( pB, "page without body." ); - pB->ChgColumns( *(const SwFmtCol*)pOld, *(const SwFmtCol*)pNew ); - rInvFlags |= 0x22; - } + assert(pOld && pNew); //COL Missing Format + if (pOld && pNew) + { + SwLayoutFrm *pB = FindBodyCont(); + assert(pB); //page without body + pB->ChgColumns( *(const SwFmtCol*)pOld, *(const SwFmtCol*)pNew ); + rInvFlags |= 0x22; + } break; case RES_HEADER: |