QRingBuffer::reserveFront(): do not leave empty array in buffer list

Fix the corner case when called on empty buffer.

Change-Id: I1316de7fbe69f3db40a7fdde06336e53d82675c9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Alex Trotsenko 2015-07-02 09:42:08 +03:00
parent a576ef4c3d
commit 964d767976

View File

@ -138,10 +138,14 @@ char *QRingBuffer::reserveFront(qint64 bytes)
if (tailBuffer == 0)
tail -= head;
buffers.prepend(QByteArray());
head = qMax(basicBlockSize, int(bytes));
if (bufferSize == 0) {
tail = head;
} else {
buffers.prepend(QByteArray());
++tailBuffer;
}
buffers.first().resize(head);
++tailBuffer;
}
head -= int(bytes);