diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-02-17 15:01:37 -0600 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-02-19 14:10:04 +0000 |
commit | e70defefd80c44646a742ff581bca9b467b8e713 (patch) | |
tree | 4437b6b4cd9dabf6b9195453b45f2bf143571b3c | |
parent | 742515639168cd35a0c2036a5bf6c46b2a3a554e (diff) |
coverity#983198 Resource leak
Change-Id: Ie8b8741fbad8e5e9f600dc1497b64ecd27515818
Reviewed-on: https://gerrit.libreoffice.org/2204
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/core/doc/docfly.cxx | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 729dff7672af..11ad91022cdd 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -811,22 +811,25 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, } // #i54336# - if ( pNewAnchorFrm && pOldAsCharAnchorPos ) + if( pOldAsCharAnchorPos ) { - // We need to handle InCntnts in a special way: - // The TxtAttribut needs to be destroyed which, unfortunately, also - // destroys the format. To avoid that, we disconnect the format from - // the attribute. - const xub_StrLen nIndx( pOldAsCharAnchorPos->nContent.GetIndex() ); - SwTxtNode* pTxtNode( pOldAsCharAnchorPos->nNode.GetNode().GetTxtNode() ); - OSL_ENSURE( pTxtNode, "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object" ); - OSL_ENSURE( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); - SwTxtAttr * const pHnt = - pTxtNode->GetTxtAttrForCharAt( nIndx, RES_TXTATR_FLYCNT ); - const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); - - // They are disconnected. We now have to destroy the attribute. - pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx ); + if ( pNewAnchorFrm) + { + // We need to handle InCntnts in a special way: + // The TxtAttribut needs to be destroyed which, unfortunately, also + // destroys the format. To avoid that, we disconnect the format from + // the attribute. + const xub_StrLen nIndx( pOldAsCharAnchorPos->nContent.GetIndex() ); + SwTxtNode* pTxtNode( pOldAsCharAnchorPos->nNode.GetNode().GetTxtNode() ); + OSL_ENSURE( pTxtNode, "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object" ); + OSL_ENSURE( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIndx, RES_TXTATR_FLYCNT ); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); + + // They are disconnected. We now have to destroy the attribute. + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx ); + } delete pOldAsCharAnchorPos; } } |