fix IOBuf self move-assignment
authorPhilip Pronin <philipp@fb.com>
Tue, 6 May 2014 22:53:39 +0000 (15:53 -0700)
committerDave Watson <davejwatson@fb.com>
Tue, 20 May 2014 19:53:58 +0000 (12:53 -0700)
Summary: Properly handle `this == &other` case.

Test Plan: fbconfig -r folly/test && fbmake runtests_opt -j32

Reviewed By: simpkins@fb.com

FB internal diff: D1314916

folly/io/IOBuf.cpp

index f8a34fd06abdc0c7714c9e7360d738d24f3c6704..28a41be5c92975f50e6f7aa203cb626b40b27801 100644 (file)
@@ -365,6 +365,10 @@ IOBuf::~IOBuf() {
 }
 
 IOBuf& IOBuf::operator=(IOBuf&& other) noexcept {
+  if (this == &other) {
+    return *this;
+  }
+
   // If we are part of a chain, delete the rest of the chain.
   while (next_ != this) {
     // Since unlink() returns unique_ptr() and we don't store it,