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:
parent
a576ef4c3d
commit
964d767976
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user