Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[pvs-studio] Protect from self assignment.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 19 Jul 2021 20:56:54 +0000 (22:56 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 19 Jul 2021 20:56:54 +0000 (22:56 +0200)
src/mc/sosp/ChunkedData.hpp

index 2846455..85f0790 100644 (file)
@@ -64,11 +64,13 @@ public:
   }
   ChunkedData& operator=(ChunkedData&& that) noexcept
   {
-    this->clear();
-    store_      = that.store_;
-    that.store_ = nullptr;
-    pagenos_    = std::move(that.pagenos_);
-    that.pagenos_.clear();
+    if (this != &that) {
+      this->clear();
+      store_      = that.store_;
+      that.store_ = nullptr;
+      pagenos_    = std::move(that.pagenos_);
+      that.pagenos_.clear();
+    }
     return *this;
   }