diff --git a/handy/net.h b/handy/net.h index 2905db7..0e3c43e 100644 --- a/handy/net.h +++ b/handy/net.h @@ -55,7 +55,7 @@ struct Buffer { Buffer& absorb(Buffer& buf); void setSuggestSize(size_t sz) { exp_ = sz; } Buffer(const Buffer& b) { copyFrom(b); } - Buffer& operator=(const Buffer& b) { delete[] buf_; buf_ = NULL; copyFrom(b); return *this; } + Buffer& operator=(const Buffer& b) { if(this == &b) return *this; delete[] buf_; buf_ = NULL; copyFrom(b); return *this; } operator Slice () { return Slice(data(), size()); } private: char* buf_; @@ -65,4 +65,4 @@ struct Buffer { void copyFrom(const Buffer& b); }; -} \ No newline at end of file +}