LSP: seek input buffer to the end before writing to it

If we receive messages with incomplete header we seek to the position
before we started to read any data from the buffer. Writing to this
buffer where the current position is not at the end results in
misordered data.

Change-Id: Ifaea5c07abee59c803ed08094ed1fdaf40d1cb7b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2018-09-13 09:47:13 +02:00
parent d490319db6
commit 8c1edd5c54

View File

@@ -645,6 +645,8 @@ bool BaseClient::sendWorkspceFolderChanges() const
void BaseClient::parseData(const QByteArray &data)
{
const qint64 preWritePosition = m_buffer.pos();
if (!m_buffer.atEnd())
m_buffer.seek(preWritePosition + m_buffer.bytesAvailable());
m_buffer.write(data);
m_buffer.seek(preWritePosition);
while (!m_buffer.atEnd()) {