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) <ogoffart@woboq.com>bb10
parent
b4ab4868bc
commit
13189360e5
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue