From d5d1425657d0dd2dc76f4938c8141a387a81a5a8 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 29 Oct 2013 11:16:27 +1000 Subject: Bug fix: CDataStream::GetAndClear() when nReadPos > 0 Changed CDataStream::GetAndClear() to use the most obvious get get and clear instead of a tricky swap(). Added a unit test for CDataStream insert/erase/GetAndClear. Note: GetAndClear() is not performance critical, it is used only by the send-a-message-to-the-network code. Bug was not noticed before now because the send-a-message code never erased from the stream. --- src/serialize.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/serialize.h') diff --git a/src/serialize.h b/src/serialize.h index 4d9aec3426..32f386b366 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -1104,8 +1104,8 @@ public: } void GetAndClear(CSerializeData &data) { - vch.swap(data); - CSerializeData().swap(vch); + data.insert(data.end(), begin(), end()); + clear(); } }; -- cgit v1.2.3