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
3287e3bd5d
commit
d876542d39
@ -319,7 +319,9 @@ divesystem_idive_packet (divesystem_idive_device_t *device, const unsigned char
|
||||
goto error;
|
||||
}
|
||||
|
||||
memcpy(answer, packet + 1, length - 2);
|
||||
if (length > 2) {
|
||||
memcpy (answer, packet + 1, length - 2);
|
||||
}
|
||||
|
||||
error:
|
||||
if (errorcode) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user