From 20a04c127de50a70014abd361e08589530a1bec1 Mon Sep 17 00:00:00 2001 From: Amos Jeffries <> Date: Sun, 9 Apr 2017 00:02:27 +1200 Subject: [PATCH] Bug 4696: move semantics regression to String class --- src/SquidString.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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; -- 2.39.5