Core/PacketIO: Fixed ByteBuffer auto-flush after b231903932

This commit is contained in:
Shauren
2020-09-06 15:39:07 +02:00
parent 18b3db71cd
commit b6ed0c7870

View File

@@ -75,6 +75,8 @@ void ByteBuffer::append(uint8 const* src, size_t cnt)
ASSERT(cnt, "Attempted to put a zero-sized value in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", _wpos, size());
ASSERT(size() < 10000000);
FlushBits();
size_t const newSize = _wpos + cnt;
if (_storage.capacity() < newSize) // custom memory allocation rules
{
@@ -88,7 +90,6 @@ void ByteBuffer::append(uint8 const* src, size_t cnt)
_storage.reserve(400000);
}
FlushBits();
if (_storage.size() < newSize)
_storage.resize(newSize);
std::memcpy(&_storage[_wpos], src, cnt);