aboutsummaryrefslogtreecommitdiff
path: root/src/serialize.h
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-10-29 11:16:27 +1000
committerGavin Andresen <gavinandresen@gmail.com>2013-10-29 11:20:14 +1000
commitd5d1425657d0dd2dc76f4938c8141a387a81a5a8 (patch)
tree5083c171ee7a73e0c7ab6956987c23ddc2cf08af /src/serialize.h
parentcd1fc2434ce80f50242e41b5e675f6d0b36045ad (diff)
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.
Diffstat (limited to 'src/serialize.h')
-rw-r--r--src/serialize.h4
1 files changed, 2 insertions, 2 deletions
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();
}
};