[Libreoffice-commits] core.git: sw/source

Caolán McNamara caolanm at redhat.com
Wed Oct 2 09:30:47 PDT 2013


 sw/source/core/doc/docfly.cxx |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit a90321e8f3a243af79c527ca8081432516043cfd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Oct 2 17:30:05 2013 +0100

    CID#983198 fully fix potential memory leak
    
    Change-Id: Ib387addbf86128170bbfd08ccce216be5a32fcae

diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index 37b711c..da85b99 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -638,11 +638,11 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
             // anchored object the complete <SwPosition> is kept, because the
             // anchor index position could be moved, if the object again is
             // anchored as character.
-            const SwPosition* pOldAsCharAnchorPos( 0L );
+            boost::scoped_ptr<const SwPosition> xOldAsCharAnchorPos;
             const RndStdIds eOldAnchorType = pContact->GetAnchorId();
             if ( !_bSameOnly && eOldAnchorType == FLY_AS_CHAR )
             {
-                pOldAsCharAnchorPos = new SwPosition( pContact->GetCntntAnchor() );
+                xOldAsCharAnchorPos.reset(new SwPosition(pContact->GetCntntAnchor()));
             }
 
             if ( _bSameOnly )
@@ -808,7 +808,7 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
             }
 
             // #i54336#
-            if( pOldAsCharAnchorPos )
+            if (xOldAsCharAnchorPos)
             {
                 if ( pNewAnchorFrm)
                 {
@@ -816,8 +816,8 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
                     // 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() );
+                    const xub_StrLen nIndx( xOldAsCharAnchorPos->nContent.GetIndex() );
+                    SwTxtNode* pTxtNode( xOldAsCharAnchorPos->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 =
@@ -827,7 +827,6 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList,
                     // They are disconnected. We now have to destroy the attribute.
                     pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx );
                 }
-                delete pOldAsCharAnchorPos;
             }
         }
     }


More information about the Libreoffice-commits mailing list