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:
Jef Driesen 2022-10-16 21:29:49 +02:00
parent c5813d624a
commit 3d388a0a96

View File

@ -163,7 +163,9 @@ deepsix_excursion_recv (deepsix_excursion_device_t *device, unsigned char grp, u
return DC_STATUS_PROTOCOL;
}
memcpy(data, packet + 4, len);
if (len) {
memcpy(data, packet + 4, len);
}
if (actual)
*actual = len;