From 4d3e564716deada2c7cd40586d4a6bf6e5efa765 Mon Sep 17 00:00:00 2001 From: Mafciejewicz Date: Fri, 10 Sep 2021 17:49:01 +0200 Subject: [PATCH] Add self reference check to copy assignment --- include/Wave.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/Wave.hpp b/include/Wave.hpp index ffea0aa..5b716ff 100644 --- a/include/Wave.hpp +++ b/include/Wave.hpp @@ -71,8 +71,14 @@ class Wave : public ::Wave { } Wave& operator=(const Wave& other) { + if (&other != this) { + return *this; + } + Unload(); set(other.Copy()); + + return *this; }; Wave& operator=(Wave&& other) {