diff --git a/re2/filtered_re2.cc b/re2/filtered_re2.cc index f0995a10..e87ffc60 100644 --- a/re2/filtered_re2.cc +++ b/re2/filtered_re2.cc @@ -43,8 +43,10 @@ FilteredRE2::FilteredRE2(FilteredRE2&& other) } FilteredRE2& FilteredRE2::operator=(FilteredRE2&& other) { - this->~FilteredRE2(); - (void) new (this) FilteredRE2(std::move(other)); + if (this != &other) { + this->~FilteredRE2(); + (void) new (this) FilteredRE2(std::move(other)); + } return *this; } diff --git a/re2/set.cc b/re2/set.cc index 3f2a1f07..9064a96e 100644 --- a/re2/set.cc +++ b/re2/set.cc @@ -50,8 +50,10 @@ RE2::Set::Set(Set&& other) } RE2::Set& RE2::Set::operator=(Set&& other) { - this->~Set(); - (void) new (this) Set(std::move(other)); + if (this != &other) { + this->~Set(); + (void) new (this) Set(std::move(other)); + } return *this; }