]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4696: move semantics regression to String class
authorAmos Jeffries <>
Sat, 8 Apr 2017 12:02:27 +0000 (00:02 +1200)
committerAmos Jeffries <>
Sat, 8 Apr 2017 12:02:27 +0000 (00:02 +1200)
src/SquidString.h

index 034b79ddf23775a155c5c3a1cf56674a19eee8ed..10de8b421d358666b85606b2c9e144d4d7b38f0d 100644 (file)
@@ -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;