summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-10-02 16:29:36 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-10-02 21:59:46 +0200
commit34e8fd7e99489e9f50a512b07c6f3923b358b4d3 (patch)
tree656c0fac86bba0300dba5e94bfa04c1a4229ddfa /filter
parente4c4c21d46ed2c8f7d117ce8d7f407474c2a12bc (diff)
ofz#3537 Direct-leak
Change-Id: Icca25565d396a36154bca0ac748554e95cd83ae9 Reviewed-on: https://gerrit.libreoffice.org/43049 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 'filter')
-rw-r--r--filter/source/graphicfilter/icgm/bitmap.cxx29
-rw-r--r--filter/source/graphicfilter/icgm/bitmap.hxx2
-rw-r--r--filter/source/graphicfilter/icgm/class4.cxx7
3 files changed, 18 insertions, 20 deletions
diff --git a/filter/source/graphicfilter/icgm/bitmap.cxx b/filter/source/graphicfilter/icgm/bitmap.cxx
index 215b46a17019..71a64eedcddc 100644
--- a/filter/source/graphicfilter/icgm/bitmap.cxx
+++ b/filter/source/graphicfilter/icgm/bitmap.cxx
@@ -347,27 +347,26 @@ void CGMBitmap::ImplInsert( CGMBitmapDescriptor& rSource, CGMBitmapDescriptor& r
rDest.mndy += rSource.mndy;
};
-CGMBitmap* CGMBitmap::GetNext()
+std::unique_ptr<CGMBitmap> CGMBitmap::GetNext()
{
- if ( pCGMBitmapDescriptor->mpBitmap && pCGMBitmapDescriptor->mbStatus )
+ std::unique_ptr<CGMBitmap> xCGMTempBitmap;
+ if (pCGMBitmapDescriptor->mpBitmap && pCGMBitmapDescriptor->mbStatus)
{
- CGMBitmap* pCGMTempBitmap = new CGMBitmap( *mpCGM );
- if ( ( (long)pCGMTempBitmap->pCGMBitmapDescriptor->mnOrientation == (long)pCGMBitmapDescriptor->mnOrientation ) &&
- ( ( ( pCGMTempBitmap->pCGMBitmapDescriptor->mnR.X == pCGMBitmapDescriptor->mnQ.X ) &&
- ( pCGMTempBitmap->pCGMBitmapDescriptor->mnR.Y == pCGMBitmapDescriptor->mnQ.Y ) ) ||
- ( ( pCGMTempBitmap->pCGMBitmapDescriptor->mnQ.X == pCGMBitmapDescriptor->mnR.X ) &&
- ( pCGMTempBitmap->pCGMBitmapDescriptor->mnQ.Y == pCGMBitmapDescriptor->mnR.Y ) ) ) )
+ xCGMTempBitmap.reset(new CGMBitmap(*mpCGM));
+ if ( ( (long)xCGMTempBitmap->pCGMBitmapDescriptor->mnOrientation == (long)pCGMBitmapDescriptor->mnOrientation ) &&
+ ( ( ( xCGMTempBitmap->pCGMBitmapDescriptor->mnR.X == pCGMBitmapDescriptor->mnQ.X ) &&
+ ( xCGMTempBitmap->pCGMBitmapDescriptor->mnR.Y == pCGMBitmapDescriptor->mnQ.Y ) ) ||
+ ( ( xCGMTempBitmap->pCGMBitmapDescriptor->mnQ.X == pCGMBitmapDescriptor->mnR.X ) &&
+ ( xCGMTempBitmap->pCGMBitmapDescriptor->mnQ.Y == pCGMBitmapDescriptor->mnR.Y ) ) ) )
{
- ImplInsert( *(pCGMTempBitmap->pCGMBitmapDescriptor), *(pCGMBitmapDescriptor) );
- delete pCGMTempBitmap;
- return nullptr;
+ ImplInsert( *(xCGMTempBitmap->pCGMBitmapDescriptor), *(pCGMBitmapDescriptor) );
+ xCGMTempBitmap.reset();
+ return xCGMTempBitmap;
}
- pCGMBitmapDescriptor.swap(pCGMTempBitmap->pCGMBitmapDescriptor);
- return pCGMTempBitmap;
+ pCGMBitmapDescriptor.swap(xCGMTempBitmap->pCGMBitmapDescriptor);
}
- else
- return nullptr;
+ return xCGMTempBitmap;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphicfilter/icgm/bitmap.hxx b/filter/source/graphicfilter/icgm/bitmap.hxx
index 586b0e7cd4d6..ccf0f043cf45 100644
--- a/filter/source/graphicfilter/icgm/bitmap.hxx
+++ b/filter/source/graphicfilter/icgm/bitmap.hxx
@@ -83,7 +83,7 @@ public:
explicit CGMBitmap( CGM& rCGM );
~CGMBitmap();
CGMBitmapDescriptor* GetBitmap() { return pCGMBitmapDescriptor.get();}
- CGMBitmap* GetNext();
+ std::unique_ptr<CGMBitmap> GetNext();
};
#endif
diff --git a/filter/source/graphicfilter/icgm/class4.cxx b/filter/source/graphicfilter/icgm/class4.cxx
index c505b39a90cf..87ce8e129769 100644
--- a/filter/source/graphicfilter/icgm/class4.cxx
+++ b/filter/source/graphicfilter/icgm/class4.cxx
@@ -309,11 +309,10 @@ void CGM::ImplDoClass4()
if ( mpBitmapInUse )
{
- CGMBitmap* pBmpDesc = mpBitmapInUse->GetNext();
- if ( pBmpDesc ) // we possibly get a bitmap back which does not fit to
+ std::unique_ptr<CGMBitmap> xBmpDesc(mpBitmapInUse->GetNext());
+ if (xBmpDesc) // we possibly get a bitmap back which does not fit to
{ // to the previous -> we need to delete this one too
- mpOutAct->DrawBitmap( pBmpDesc->GetBitmap() );
- delete pBmpDesc;
+ mpOutAct->DrawBitmap(xBmpDesc->GetBitmap());
}
}
else