summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-11-23 11:03:43 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-11-23 11:03:46 (GMT)
commit366af17676a87943c8a7c2380a8819bdd3815878 (patch)
tree378efb9fe91abd68be687780276dbcffbf6eb457 /src/corelib
parent9619f5e27cbed9b45188112c934733e9f069b8ca (diff)
parentb7692016f282251002b3e85dfcb5567bd91a12c0 (diff)
downloadQt-366af17676a87943c8a7c2380a8819bdd3815878.zip
Qt-366af17676a87943c8a7c2380a8819bdd3815878.tar.gz
Qt-366af17676a87943c8a7c2380a8819bdd3815878.tar.bz2
Merge commit 'b7692016f282251002b3e85dfcb5567bd91a12c0' of oslo-staging-1 into 4.6
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qiodevice.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index b84961f..0e5a2de 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1157,6 +1157,10 @@ QByteArray QIODevice::readLine(qint64 maxSize)
// If resize fails or maxSize == 0, read incrementally
if (maxSize == 0)
maxSize = INT_MAX;
+
+ // The first iteration needs to leave an extra byte for the terminating null
+ result.resize(1);
+
qint64 readResult;
do {
result.resize(int(qMin(maxSize, result.size() + QIODEVICE_BUFFERSIZE)));
@@ -1164,7 +1168,7 @@ QByteArray QIODevice::readLine(qint64 maxSize)
if (readResult > 0 || readBytes == 0)
readBytes += readResult;
} while (readResult == QIODEVICE_BUFFERSIZE
- && result[int(readBytes)] != '\n');
+ && result[int(readBytes - 1)] != '\n');
} else
readBytes = readLine(result.data(), result.size());