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

Caolán McNamara caolanm at redhat.com
Thu Apr 12 09:34:05 UTC 2018


 sw/source/core/layout/fly.cxx |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

New commits:
commit 1d78ddc4a7277b05f05ba36d0275e073587c9b64
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Apr 12 08:59:06 2018 +0100

    coverity#1434220 Resource leak
    
    Change-Id: If38eb14445c2a2509994e20bdbd00f449819c666
    Reviewed-on: https://gerrit.libreoffice.org/52754
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index cfdcec89b779..90cf8c5ae5d1 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2466,8 +2466,8 @@ bool SwFlyFrame::GetContour( tools::PolyPolygon&   rContour,
             // OD 16.04.2003 #i13147# - determine <GraphicObject> instead of <Graphic>
             // in order to avoid load of graphic, if <SwNoTextNode> contains a graphic
             // node and method is called for paint.
+            std::unique_ptr<GraphicObject> xTmpGrfObj;
             const GraphicObject* pGrfObj = nullptr;
-            bool bGrfObjCreated = false;
             const SwGrfNode* pGrfNd = pNd->GetGrfNode();
             if ( pGrfNd && _bForPaint )
             {
@@ -2475,11 +2475,11 @@ bool SwFlyFrame::GetContour( tools::PolyPolygon&   rContour,
             }
             else
             {
-                pGrfObj = new GraphicObject( pNd->GetGraphic() );
-                bGrfObjCreated = true;
+                xTmpGrfObj.reset(new GraphicObject(pNd->GetGraphic()));
+                pGrfObj = xTmpGrfObj.get();
             }
-            OSL_ENSURE( pGrfObj, "SwFlyFrame::GetContour() - No Graphic/GraphicObject found at <SwNoTextNode>." );
-            if ( pGrfObj && pGrfObj->GetType() != GraphicType::NONE )
+            assert(pGrfObj && "SwFlyFrame::GetContour() - No Graphic/GraphicObject found at <SwNoTextNode>.");
+            if (pGrfObj->GetType() != GraphicType::NONE)
             {
                 if( !pNd->HasContour() )
                 {
@@ -2538,10 +2538,7 @@ bool SwFlyFrame::GetContour( tools::PolyPolygon&   rContour,
                     }
                 }
                 // OD 17.04.2003 #i13147# - destroy created <GraphicObject>.
-                if ( bGrfObjCreated )
-                {
-                    delete pGrfObj;
-                }
+                xTmpGrfObj.reset();
                 rContour.Move( aOrig.Left(), aOrig.Top() );
                 if( !aClip.Width() )
                     aClip.Width( 1 );


More information about the Libreoffice-commits mailing list