From 0327cbaa2ab48b8da8aad181f55ce4e48fe3946c Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Wed, 6 Feb 2013 12:02:47 +0100 Subject: [PATCH] include/buffer.h: fix operator= Fix operator=: return "iterator&" instead of 'iterator'. Check if 'this' equals 'other' before set anything. Signed-off-by: Danny Al-Gaaf --- src/include/buffer.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/include/buffer.h b/src/include/buffer.h index 9a635bdb5d0f7..4f87ed7453b86 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -248,7 +248,7 @@ public: p(other.p), p_off(other.p_off) {} - iterator operator=(const iterator& other) { + iterator& operator=(const iterator& other) { if (this != &other) { bl = other.bl; ls = other.ls; @@ -305,8 +305,10 @@ public: list(const list& other) : _buffers(other._buffers), _len(other._len), last_p(this) { } list& operator= (const list& other) { - _buffers = other._buffers; - _len = other._len; + if (this != &other) { + _buffers = other._buffers; + _len = other._len; + } return *this; } -- 2.39.5