From 350ab228857edf7928b299722412f9cf65b00a19 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Mon, 13 Oct 2014 11:14:16 +0300 Subject: [PATCH] Make QRingBuffer::ungetChar() not leave empty array in buffer list Change-Id: Ic692693132f0c316ad068cad5423ca8fd32bd40d Reviewed-by: Oswald Buddenhagen --- src/corelib/tools/qringbuffer_p.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index 2279f1bc2a..27d0791bd2 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -175,10 +175,14 @@ public: inline void ungetChar(char c) { --head; if (head < 0) { - buffers.prepend(QByteArray()); + if (bufferSize != 0) { + buffers.prepend(QByteArray()); + ++tailBuffer; + } else { + tail = basicBlockSize; + } buffers.first().resize(basicBlockSize); head = basicBlockSize - 1; - ++tailBuffer; } buffers.first()[head] = c; ++bufferSize;