From c90ecac48eb016bae51c798e43f0c29a8401fb23 Mon Sep 17 00:00:00 2001 From: ntfshard Date: Mon, 24 Aug 2015 01:50:42 +0300 Subject: [PATCH] Addtional check for TPPLPoly::operator= --- xs/src/polypartition.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xs/src/polypartition.cpp b/xs/src/polypartition.cpp index bdd23f6f3..700cd0974 100644 --- a/xs/src/polypartition.cpp +++ b/xs/src/polypartition.cpp @@ -74,11 +74,13 @@ TPPLPoly::TPPLPoly(const TPPLPoly &src) { } TPPLPoly& TPPLPoly::operator=(const TPPLPoly &src) { - Clear(); - hole = src.hole; - numpoints = src.numpoints; - points = new TPPLPoint[numpoints]; - memcpy(points, src.points, numpoints*sizeof(TPPLPoint)); + if(&src != this) { + Clear(); + hole = src.hole; + numpoints = src.numpoints; + points = new TPPLPoint[numpoints]; + memcpy(points, src.points, numpoints*sizeof(TPPLPoint)); + } return *this; }