From 934b3c4f8123eef513a7fff861a2afeb3c4abbf0 Mon Sep 17 00:00:00 2001 From: Philip Pronin Date: Tue, 6 May 2014 15:53:39 -0700 Subject: [PATCH] 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 --- folly/io/IOBuf.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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, -- 2.34.1