Fix setBuffer of the OutputMessage class

This commit is contained in:
Konrad Kuśnierz 2019-03-06 14:48:46 +01:00 committed by GitHub
parent 92532a958e
commit 1c8cea513c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -38,11 +38,11 @@ void OutputMessage::reset()
void OutputMessage::setBuffer(const std::string& buffer) void OutputMessage::setBuffer(const std::string& buffer)
{ {
int len = buffer.size(); int len = buffer.size();
checkWrite(MAX_HEADER_SIZE + len); reset();
memcpy(m_buffer + MAX_HEADER_SIZE, buffer.c_str(), len); checkWrite(len);
m_writePos = MAX_HEADER_SIZE; memcpy((char*)(m_buffer + m_writePos), buffer.c_str(), len);
m_headerPos = MAX_HEADER_SIZE; m_writePos += len;
m_messageSize = len; m_messageSize += len;
} }
void OutputMessage::addU8(uint8 value) void OutputMessage::addU8(uint8 value)