summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-23 14:09:52 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-10-23 14:54:51 +0100
commit5be04f59c9d9505a03239347de7ab4c0fdb452e7 (patch)
treef10aa88d5eb65d0ae77bb47f2a8418a4bde91831 /tools
parent15037b018f81d6e5d5bb21921845a11922c301ca (diff)
coverity#440777 Resource leak in object
rework to avoid the warning Change-Id: Id104c01b04e07ffaaf503a842c978acbc8a22a19
Diffstat (limited to 'tools')
-rw-r--r--tools/source/generic/poly.cxx36
1 files changed, 20 insertions, 16 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index ce9aa918b89d..a588719e4a59 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -34,6 +34,7 @@
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/curve/b2dcubicbezier.hxx>
+#include <memory>
#include <vector>
#include <iterator>
#include <algorithm>
@@ -1094,37 +1095,40 @@ protected:
class ImplPolygonPointFilter : public ImplPointFilter
{
-public:
- ImplPolygon* mpPoly; // Don't remove, assigned by polygon
+ std::unique_ptr<ImplPolygon> mxPoly;
sal_uInt16 mnSize;
+public:
+ ImplPolygonPointFilter(sal_uInt16 nDestSize)
+ : mxPoly(new ImplPolygon(nDestSize))
+ , mnSize(0)
+ {
+ }
- ImplPolygonPointFilter( sal_uInt16 nDestSize ) :
- mnSize( 0 )
- {
- mpPoly = new ImplPolygon( nDestSize );
- }
-
- virtual ~ImplPolygonPointFilter() {}
+ virtual ~ImplPolygonPointFilter()
+ {
+ }
virtual void LastPoint() SAL_OVERRIDE;
virtual void Input( const Point& rPoint ) SAL_OVERRIDE;
+
+ ImplPolygon* release() { return mxPoly.release(); }
};
void ImplPolygonPointFilter::Input( const Point& rPoint )
{
- if ( !mnSize || (rPoint != mpPoly->mpPointAry[mnSize-1]) )
+ if ( !mnSize || (rPoint != mxPoly->mpPointAry[mnSize-1]) )
{
mnSize++;
- if ( mnSize > mpPoly->mnPoints )
- mpPoly->ImplSetSize( mnSize );
- mpPoly->mpPointAry[mnSize-1] = rPoint;
+ if ( mnSize > mxPoly->mnPoints )
+ mxPoly->ImplSetSize( mnSize );
+ mxPoly->mpPointAry[mnSize-1] = rPoint;
}
}
void ImplPolygonPointFilter::LastPoint()
{
- if ( mnSize < mpPoly->mnPoints )
- mpPoly->ImplSetSize( mnSize );
+ if ( mnSize < mxPoly->mnPoints )
+ mxPoly->ImplSetSize( mnSize );
};
class ImplEdgePointFilter : public ImplPointFilter
@@ -1311,7 +1315,7 @@ void Polygon::Clip( const Rectangle& rRect, bool bPolygon )
else
delete mpImplPolygon;
}
- mpImplPolygon = aPolygon.mpPoly;
+ mpImplPolygon = aPolygon.release();
}
Rectangle Polygon::GetBoundRect() const