summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2010-05-06 17:07:39 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2010-05-06 17:27:22 (GMT)
commit18411bfd474b05fd427b3d763af2fcc96e3e73df (patch)
tree589087528a14b11a2ead1e9368d179e0f74a2b2b /src
parent98280b5e5d2be28dffcc4a6b642996dd6ab8b79f (diff)
downloadQt-18411bfd474b05fd427b3d763af2fcc96e3e73df.zip
Qt-18411bfd474b05fd427b3d763af2fcc96e3e73df.tar.gz
Qt-18411bfd474b05fd427b3d763af2fcc96e3e73df.tar.bz2
Fixed bug in QIODevice::read after first reading 0 bytes.
Change 02532ec80375c686503c4250c6ad6bb211515ec8 removed the early-exit for 0 byte reads, causing us to hit code that assumed the buffer was empty since nothing was read. It would thus read more into the end of the buffer, causing the buffer to grow bigger than QIODEVICE_BUFFERSIZE. Next, if the actual number of bytes we wanted to read was bigger than the original buffer size we'd read the same data twice. Reviewed-by: João Abecasis Reviewed-by: Thiago Macieira
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qiodevice.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index bb11d6b..223df9b 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -810,6 +810,9 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
}
}
+ if (!maxSize)
+ return readSoFar;
+
if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) {
// In buffered mode, we try to fill up the QIODevice buffer before
// we do anything else.