diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-05-04 13:16:14 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-05-04 13:19:31 +0200 |
commit | 7f8719e663edae8b08d34cc67cb5000e8402d3d7 (patch) | |
tree | b098d2c8077a88c2ada577ac874e1416adaf66f7 /src/corelib/io | |
parent | af851c290b7cea22f26bb8c852b0029696469d74 (diff) | |
parent | eb82959d6688f9e58be4b67670afba3649f1f799 (diff) |
Merge remote-tracking branch 'origin/5.5' into HEAD
Change-Id: I487a4b7c05687a10c498ac219c31367d4db6fbc0
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 47484ad596..e73a200fb4 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -989,6 +989,10 @@ QByteArray QIODevice::readAll() // Size is unknown, read incrementally. qint64 readResult; do { + if (quint64(readBytes) + QIODEVICE_BUFFERSIZE > QByteArray::MaxSize) { + // If resize would fail, don't read more, return what we have. + break; + } result.resize(readBytes + QIODEVICE_BUFFERSIZE); readResult = read(result.data() + readBytes, QIODEVICE_BUFFERSIZE); if (readResult > 0 || readBytes == 0) diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 6149a04a74..5fe4cfef9d 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -447,6 +447,9 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) bytesRead = device->read(buf, sizeof(buf)); } + if (bytesRead <= 0) + return false; + #ifndef QT_NO_TEXTCODEC // codec auto detection, explicitly defaults to locale encoding if the // codec has been set to 0. @@ -470,9 +473,6 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) qt_prettyDebug(buf, qMin(32,int(bytesRead)) , int(bytesRead)).constData(), int(sizeof(buf)), int(bytesRead)); #endif - if (bytesRead <= 0) - return false; - int oldReadBufferSize = readBuffer.size(); #ifndef QT_NO_TEXTCODEC // convert to unicode |