summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2015-07-02 09:42:08 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2015-07-10 16:34:53 +0000
commit964d76797657b64206f8bbd54eeb69ce27d66b56 (patch)
tree5f1530fa55492724b9a8e9378a5fdf24206699ff /src/corelib
parenta576ef4c3d06d54eab8e4e7fbb89b7a00df6eba6 (diff)
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>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qringbuffer.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index 658267a521..85cfdaf129 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -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);