hidapi: Avoid memcpy'ing to NULL.
(This fix was originally from @themightyoarfish on GitHub. Thanks!) Fixes #8428. Reference PR #8431.main
parent
4d1aecc225
commit
c6d9fb1ad7
|
@ -1230,7 +1230,9 @@ static int return_data(hid_device *dev, unsigned char *data, size_t length)
|
|||
return buffer (data), and delete the liked list item. */
|
||||
struct input_report *rpt = dev->input_reports;
|
||||
size_t len = (length < rpt->len)? length: rpt->len;
|
||||
memcpy(data, rpt->data, len);
|
||||
if (data != NULL) {
|
||||
memcpy(data, rpt->data, len);
|
||||
}
|
||||
dev->input_reports = rpt->next;
|
||||
free(rpt->data);
|
||||
free(rpt);
|
||||
|
|
Loading…
Reference in New Issue