From 440523b022070335714063cc4889292eaa3376c8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 21 Aug 2020 18:17:45 +0100 Subject: CompressPacket: reserve CompressedSize, not the uncompressed size + Assign the length data to a_CompressedData to overwrite it, mirroring the behaviour of cByteBuffer::ReadAll --- src/Protocol/Protocol_1_8.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Protocol/Protocol_1_8.cpp') diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 79fd00138..ee72e14fb 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -1743,7 +1743,7 @@ bool cProtocol_1_8_0::CompressPacket(const AString & a_Packet, AString & a_Compr LengthHeaderBuffer.ReadAll(LengthData); a_CompressedData.reserve(LengthData.size() + UncompressedSize); - a_CompressedData.append(LengthData.data(), LengthData.size()); + a_CompressedData.assign(LengthData.data(), LengthData.size()); a_CompressedData.append(a_Packet); return true; @@ -1794,8 +1794,8 @@ bool cProtocol_1_8_0::CompressPacket(const AString & a_Packet, AString & a_Compr AString LengthData; LengthHeaderBuffer.ReadAll(LengthData); - a_CompressedData.reserve(LengthData.size() + DataSize); - a_CompressedData.append(LengthData.data(), LengthData.size()); + a_CompressedData.reserve(LengthData.size() + CompressedSize); + a_CompressedData.assign(LengthData.data(), LengthData.size()); a_CompressedData.append(CompressedData, CompressedSize); return true; -- cgit v1.2.3