From: Philip Pronin Date: Tue, 6 May 2014 22:53:39 +0000 (-0700) Subject: fix IOBuf self move-assignment X-Git-Tag: v0.22.0~555 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=934b3c4f8123eef513a7fff861a2afeb3c4abbf0;p=folly.git fix IOBuf self move-assignment 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 --- diff --git a/folly/io/IOBuf.cpp b/folly/io/IOBuf.cpp index f8a34fd0..28a41be5 100644 --- a/folly/io/IOBuf.cpp +++ b/folly/io/IOBuf.cpp @@ -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,