Fixed a newly introduced memory leak into the Clipper library,

made all Clipper interfaces non-virtual.
This commit is contained in:
bubnikv 2017-03-08 20:27:03 +01:00
parent 4426e47e2a
commit 336f86c101
2 changed files with 6 additions and 4 deletions

View file

@ -1356,6 +1356,8 @@ void Clipper::DisposeAllOutRecs()
{ {
for (OutPt *pts : m_OutPts) for (OutPt *pts : m_OutPts)
delete[] pts; delete[] pts;
for (OutRec *rec : m_PolyOuts)
delete rec;
m_OutPts.clear(); m_OutPts.clear();
m_OutPtsFree = nullptr; m_OutPtsFree = nullptr;
m_OutPtsChunkLast = m_OutPtsChunkSize; m_OutPtsChunkLast = m_OutPtsChunkSize;

View file

@ -294,10 +294,10 @@ class ClipperBase
{ {
public: public:
ClipperBase() : m_UseFullRange(false), m_HasOpenPaths(false) {} ClipperBase() : m_UseFullRange(false), m_HasOpenPaths(false) {}
virtual ~ClipperBase() { Clear(); } ~ClipperBase() { Clear(); }
bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed); bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed); bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed);
virtual void Clear(); void Clear();
IntRect GetBounds(); IntRect GetBounds();
// By default, when three or more vertices are collinear in input polygons (subject or clip), the Clipper object removes the 'inner' vertices before clipping. // By default, when three or more vertices are collinear in input polygons (subject or clip), the Clipper object removes the 'inner' vertices before clipping.
// When enabled the PreserveCollinear property prevents this default behavior to allow these inner vertices to appear in the solution. // When enabled the PreserveCollinear property prevents this default behavior to allow these inner vertices to appear in the solution.
@ -306,7 +306,7 @@ public:
protected: protected:
bool AddPathInternal(const Path &pg, int highI, PolyType PolyTyp, bool Closed, TEdge* edges); bool AddPathInternal(const Path &pg, int highI, PolyType PolyTyp, bool Closed, TEdge* edges);
TEdge* AddBoundsToLML(TEdge *e, bool IsClosed); TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
virtual void Reset(); void Reset();
TEdge* ProcessBound(TEdge* E, bool IsClockwise); TEdge* ProcessBound(TEdge* E, bool IsClockwise);
TEdge* DescendToMin(TEdge *&E); TEdge* DescendToMin(TEdge *&E);
void AscendToMax(TEdge *&E, bool Appending, bool IsClosed); void AscendToMax(TEdge *&E, bool Appending, bool IsClosed);
@ -326,7 +326,7 @@ protected:
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
class Clipper : public virtual ClipperBase class Clipper : public ClipperBase
{ {
public: public:
Clipper(int initOptions = 0); Clipper(int initOptions = 0);