From e0e34f6a53278121f779f34e8e25cf0716b11e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Wed, 11 May 2022 14:08:55 +0200 Subject: [PATCH] Fixed a memory leak in the move assignment operator in ExtrusionEntityCollection. --- src/libslic3r/ExtrusionEntity.hpp | 2 +- src/libslic3r/ExtrusionEntityCollection.hpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/ExtrusionEntity.hpp b/src/libslic3r/ExtrusionEntity.hpp index 52a8a563c..e72a7b914 100644 --- a/src/libslic3r/ExtrusionEntity.hpp +++ b/src/libslic3r/ExtrusionEntity.hpp @@ -85,7 +85,7 @@ public: virtual ExtrusionEntity* clone() const = 0; // Create a new object, initialize it with this object using the move semantics. virtual ExtrusionEntity* clone_move() = 0; - virtual ~ExtrusionEntity() {} + virtual ~ExtrusionEntity() = default; virtual void reverse() = 0; virtual const Point& first_point() const = 0; virtual const Point& last_point() const = 0; diff --git a/src/libslic3r/ExtrusionEntityCollection.hpp b/src/libslic3r/ExtrusionEntityCollection.hpp index 6e62a45fd..1ecda7dd5 100644 --- a/src/libslic3r/ExtrusionEntityCollection.hpp +++ b/src/libslic3r/ExtrusionEntityCollection.hpp @@ -36,9 +36,13 @@ public: ExtrusionEntityCollection(ExtrusionEntityCollection &&other) : entities(std::move(other.entities)), no_sort(other.no_sort) {} explicit ExtrusionEntityCollection(const ExtrusionPaths &paths); ExtrusionEntityCollection& operator=(const ExtrusionEntityCollection &other); - ExtrusionEntityCollection& operator=(ExtrusionEntityCollection &&other) - { this->entities = std::move(other.entities); this->no_sort = other.no_sort; return *this; } - ~ExtrusionEntityCollection() { clear(); } + ExtrusionEntityCollection& operator=(ExtrusionEntityCollection &&other) { + this->clear(); + this->entities = std::move(other.entities); + this->no_sort = other.no_sort; + return *this; + } + ~ExtrusionEntityCollection() override { clear(); } explicit operator ExtrusionPaths() const; bool is_collection() const override { return true; }