diff options
author | Marc Mutz <[email protected]> | 2016-01-06 13:31:11 +0100 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2016-01-12 06:11:53 +0000 |
commit | 13189360e50a429ee43ce927c29ebcd3948619b7 (patch) | |
tree | a108ca76c2ff9dab68f881124a3cb96c00ff335b | |
parent | b4ab4868bc8422e09590d13d35c2bba7a195ccf5 (diff) |
Fix UB in QFileDevice::writeData()
Passing nullptr as the 2nd argument of memcpy
constitutes undefined behavior.
Fix by protecting the block with 'if (len)',
which, presumably, is the only valid case
where 'data' may be nullptr.
Change-Id: I7647d7e0808b1f26444ea3cf8bbf5cda9ddc9e6c
Reviewed-by: Olivier Goffart (Woboq GmbH) <[email protected]>
-rw-r--r-- | src/corelib/io/qfiledevice.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index 3ee0e335738..2d6be5fb802 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -560,7 +560,7 @@ qint64 QFileDevice::writeData(const char *data, qint64 len) char *writePointer = d->writeBuffer.reserve(len); if (len == 1) *writePointer = *data; - else + else if (len) ::memcpy(writePointer, data, len); return len; } |