Skip to content

Commit

Permalink
clear buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Feb 27, 2022
1 parent 7492f4e commit 410aeda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sources/flatbufserver/FlatBufferConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ void FlatBufferConnection::readData()

// extract message only and remove header + msg from buffer :: QByteArray::remove() does not return the removed data
const QByteArray msg = _receiveBuffer.mid(4, messageSize);
_receiveBuffer.remove(0, messageSize + 4);

if (_receiveBuffer.size() == messageSize + 4)
_receiveBuffer.clear();
else
_receiveBuffer.remove(0, messageSize + 4);

const uint8_t* msgData = reinterpret_cast<const uint8_t*>(msg.constData());
flatbuffers::Verifier verifier(msgData, messageSize);
Expand Down

0 comments on commit 410aeda

Please sign in to comment.