diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 88e41092a6..87e46bff09 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -558,7 +558,8 @@ protected: qint64 readData(char *data, qint64 maxSize) override { maxSize = qMin(maxSize, qint64(buf->size() - offset)); - memcpy(data, buf->constData() + offset, maxSize); + if (maxSize > 0) + memcpy(data, buf->constData() + offset, maxSize); offset += maxSize; return maxSize; } @@ -601,13 +602,15 @@ protected: qint64 readData(char *data, qint64 maxSize) override { maxSize = qMin(maxSize, qint64(buf.size() - pos())); - memcpy(data, buf.constData() + pos(), maxSize); + if (maxSize > 0) + memcpy(data, buf.constData() + pos(), maxSize); return maxSize; } qint64 writeData(const char *data, qint64 maxSize) override { maxSize = qMin(maxSize, qint64(buf.size() - pos())); - memcpy(buf.data() + pos(), data, maxSize); + if (maxSize > 0) + memcpy(buf.data() + pos(), data, maxSize); return maxSize; }