From: Amos Jeffries <> Date: Sat, 8 Apr 2017 12:02:27 +0000 (+1200) Subject: Bug 4696: move semantics regression to String class X-Git-Tag: M-staged-PR71~202 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20a04c1;p=thirdparty%2Fsquid.git Bug 4696: move semantics regression to String class --- diff --git a/src/SquidString.h b/src/SquidString.h index 034b79ddf2..10de8b421d 100644 --- a/src/SquidString.h +++ b/src/SquidString.h @@ -28,7 +28,10 @@ public: String(); String(char const *); String(String const &); - String(String &&) = default; + String(String && S) : size_(S.size_), len_(S.len_), buf_(S.buf_) { + S.buf_ = nullptr; // S is about to be destructed + S.size_ = S.len_ = 0; + } ~String(); typedef size_t size_type; //storage size intentionally unspecified @@ -36,7 +39,18 @@ public: String &operator =(char const *); String &operator =(String const &); - String &operator =(String &&) = default; + String &operator =(String && S) { + if (this != &S) { + size_ = S.size_; + len_ = S.len_; + buf_ = S.buf_; + S.size_ = 0; + S.len_ = 0; + S.buf_ = nullptr; // S is about to be destructed + } + return *this; + } + bool operator ==(String const &) const; bool operator !=(String const &) const;