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.
This commit is contained in:
Gavin Andresen
2013-10-29 11:16:27 +10:00
parent cd1fc2434c
commit d5d1425657
2 changed files with 50 additions and 2 deletions

View File

@ -1104,8 +1104,8 @@ public:
}
void GetAndClear(CSerializeData &data) {
vch.swap(data);
CSerializeData().swap(vch);
data.insert(data.end(), begin(), end());
clear();
}
};