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>
This commit is contained in:
Norbert Thiebaud
2013-02-17 15:01:37 -06:00
committed by Caolán McNamara
parent 7425156391
commit e70defefd8

View File

@@ -811,22 +811,25 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
} }
// #i54336# // #i54336#
if ( pNewAnchorFrm && pOldAsCharAnchorPos ) if( pOldAsCharAnchorPos )
{ {
// We need to handle InCntnts in a special way: if ( pNewAnchorFrm)
// The TxtAttribut needs to be destroyed which, unfortunately, also {
// destroys the format. To avoid that, we disconnect the format from // We need to handle InCntnts in a special way:
// the attribute. // The TxtAttribut needs to be destroyed which, unfortunately, also
const xub_StrLen nIndx( pOldAsCharAnchorPos->nContent.GetIndex() ); // destroys the format. To avoid that, we disconnect the format from
SwTxtNode* pTxtNode( pOldAsCharAnchorPos->nNode.GetNode().GetTxtNode() ); // the attribute.
OSL_ENSURE( pTxtNode, "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object" ); const xub_StrLen nIndx( pOldAsCharAnchorPos->nContent.GetIndex() );
OSL_ENSURE( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); SwTxtNode* pTxtNode( pOldAsCharAnchorPos->nNode.GetNode().GetTxtNode() );
SwTxtAttr * const pHnt = OSL_ENSURE( pTxtNode, "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object" );
pTxtNode->GetTxtAttrForCharAt( nIndx, RES_TXTATR_FLYCNT ); OSL_ENSURE( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); 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. // They are disconnected. We now have to destroy the attribute.
pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx ); pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx );
}
delete pOldAsCharAnchorPos; delete pOldAsCharAnchorPos;
} }
} }