[qwaq] Be paranoid about memcpy and null pointers

Although I suspect memcpy does the right thing when the byte count is 0,
the man page wasn't explicit and this is more portable.
This commit is contained in:
Bill Currie 2021-09-26 12:05:16 +09:00
parent 349f8067c3
commit 1d86a18eb1

View file

@ -650,8 +650,12 @@ bi_get_device_info (progs_t *pr)
in_axisinfo_t *axes = PR_Zone_Malloc (pr, axis_buffer->size);
in_buttoninfo_t *buttons = PR_Zone_Malloc (pr, button_buffer->size);
memcpy (axes, axis_buffer->str, axis_buffer->size);
memcpy (buttons, button_buffer->str, button_buffer->size);
if (axes) {
memcpy (axes, axis_buffer->str, axis_buffer->size);
}
if (buttons) {
memcpy (buttons, button_buffer->str, button_buffer->size);
}
devinfo->name = PR_SetDynamicString (pr, name_string->str);
devinfo->id = PR_SetDynamicString (pr, id_string->str);