sw/source/core/doc/docfly.cxx | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
New commits: commit e70defefd80c44646a742ff581bca9b467b8e713 Author: Norbert Thiebaud <nthieb...@gmail.com> Date: Sun Feb 17 15:01:37 2013 -0600 coverity#983198 Resource leak Change-Id: Ie8b8741fbad8e5e9f600dc1497b64ecd27515818 Reviewed-on: https://gerrit.libreoffice.org/2204 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 729dff7..11ad910 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; } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits