summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-04-12 08:59:06 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-04-12 11:32:49 +0200
commit1d78ddc4a7277b05f05ba36d0275e073587c9b64 (patch)
tree43a5c41921a011641d6d2434573ff76f05974622 /sw
parent84e2614a75a615d6c8584b13a69b3368d2a12a3d (diff)
coverity#1434220 Resource leak
Change-Id: If38eb14445c2a2509994e20bdbd00f449819c666 Reviewed-on: https://gerrit.libreoffice.org/52754 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/layout/fly.cxx15
1 files changed, 6 insertions, 9 deletions
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 );