diff options
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 7b0557a497..06f7fb17cd 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -832,7 +832,7 @@ qint64 QIODevice::read(char *data, qint64 maxSize) // In buffered mode, we try to fill up the QIODevice buffer before // we do anything else. // buffer is empty at this point, try to fill it - int bytesToBuffer = QIODEVICE_BUFFERSIZE; + const int bytesToBuffer = QIODEVICE_BUFFERSIZE; char *writePointer = d->buffer.reserve(bytesToBuffer); // Make sure the device is positioned correctly. @@ -1013,6 +1013,8 @@ QByteArray QIODevice::readAll() // flush internal read buffer if (!(d->openMode & Text) && !d->buffer.isEmpty()) { + if (d->buffer.size() >= INT_MAX) + return QByteArray(); result = d->buffer.readAll(); readBytes = result.size(); d->pos += readBytes; @@ -1031,6 +1033,8 @@ QByteArray QIODevice::readAll() } else { // Read it all in one go. // If resize fails, don't read anything. + if (readBytes + theSize - d->pos > INT_MAX) + return QByteArray(); result.resize(int(readBytes + theSize - d->pos)); readBytes += read(result.data() + readBytes, result.size() - readBytes); } |