diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2015-05-08 16:17:00 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2015-05-11 07:32:40 +0000 |
commit | ada8f1985d1f04440fca97894192748d98e47441 (patch) | |
tree | 208e0bb8e815feb809be5615e1a3fb21f18e3382 /src/corelib/io/qiodevice.cpp | |
parent | bf06924f3ffd22747c93a720caa501d8478dcbe6 (diff) |
Check the maximum size of a QByteArray more precisely
Also document that the QByteArrray::MaxSize takes a trailing '\0' into
account.
Change-Id: I89e9a0d1a80a49b33efbac16ff7aa2a98f0e5670
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index e73a200fb4..d68f33287d 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -989,7 +989,7 @@ QByteArray QIODevice::readAll() // Size is unknown, read incrementally. qint64 readResult; do { - if (quint64(readBytes) + QIODEVICE_BUFFERSIZE > QByteArray::MaxSize) { + if (quint64(readBytes) + QIODEVICE_BUFFERSIZE >= QByteArray::MaxSize) { // If resize would fail, don't read more, return what we have. break; } @@ -1001,7 +1001,7 @@ QByteArray QIODevice::readAll() } else { // Read it all in one go. // If resize fails, don't read anything. - if (quint64(readBytes + theSize - d->pos) > QByteArray::MaxSize) + if (quint64(readBytes + theSize - d->pos) >= QByteArray::MaxSize) return QByteArray(); result.resize(int(readBytes + theSize - d->pos)); readBytes += read(result.data() + readBytes, result.size() - readBytes); |