Don't pass a NULL pointer to memcpy
The memcpy and related functions expects a valid pointer, even if the size is zero. Most libc implementations will handle a NULL pointer just fine, but that's not guaranteed. Simply skip the call when there is nothing to copy.
This commit is contained in:
parent
564958f927
commit
b3144ac26b
@ -117,7 +117,9 @@ tecdiving_divecomputereu_send (tecdiving_divecomputereu_device_t *device, unsign
|
||||
(size >> 24) & 0xFF,
|
||||
cmd,
|
||||
};
|
||||
memcpy(packet + 7, data, size);
|
||||
if (size) {
|
||||
memcpy(packet + 7, data, size);
|
||||
}
|
||||
crc = checksum_crc (packet + 1, size + 6, 0);
|
||||
packet[size + 7] = (crc >> 8) & 0xFF;
|
||||
packet[size + 8] = (crc ) & 0xFF;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user