diff options
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index f5b17318be..c4fc040685 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -120,6 +120,14 @@ static void checkWarnMessage(const QIODevice *device, const char *function, cons } \ } while (0) +#define CHECK_MAXBYTEARRAYSIZE(function) \ + do { \ + if (maxSize >= MaxByteArraySize) { \ + checkWarnMessage(this, #function, "maxSize argument exceeds QByteArray size limit"); \ + maxSize = MaxByteArraySize - 1; \ + } \ + } while (0) + #define CHECK_WRITABLE(function, returnType) \ do { \ if ((d->openMode & WriteOnly) == 0) { \ @@ -1149,17 +1157,13 @@ QByteArray QIODevice::read(qint64 maxSize) QByteArray result; CHECK_MAXLEN(read, result); + CHECK_MAXBYTEARRAYSIZE(read); #if defined QIODEVICE_DEBUG printf("%p QIODevice::read(%lld), d->pos = %lld, d->buffer.size() = %lld\n", this, maxSize, d->pos, d->buffer.size()); #endif - if (maxSize >= MaxByteArraySize) { - checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit"); - maxSize = MaxByteArraySize - 1; - } - qint64 readBytes = 0; if (maxSize) { result.resize(int(maxSize)); @@ -1393,17 +1397,13 @@ QByteArray QIODevice::readLine(qint64 maxSize) QByteArray result; CHECK_MAXLEN(readLine, result); + CHECK_MAXBYTEARRAYSIZE(readLine); #if defined QIODEVICE_DEBUG printf("%p QIODevice::readLine(%lld), d->pos = %lld, d->buffer.size() = %lld\n", this, maxSize, d->pos, d->buffer.size()); #endif - if (maxSize >= MaxByteArraySize) { - qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit"); - maxSize = MaxByteArraySize - 1; - } - result.resize(int(maxSize)); qint64 readBytes = 0; if (!result.size()) { |