mirror of https://github.com/libsdl-org/SDL
hidapi: Avoid memcpy'ing to NULL.
(This fix was originally from @themightyoarfish on GitHub. Thanks!) Fixes #8428. Reference PR #8431.
This commit is contained in:
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. */
|
return buffer (data), and delete the liked list item. */
|
||||||
struct input_report *rpt = dev->input_reports;
|
struct input_report *rpt = dev->input_reports;
|
||||||
size_t len = (length < rpt->len)? length: rpt->len;
|
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;
|
dev->input_reports = rpt->next;
|
||||||
free(rpt->data);
|
free(rpt->data);
|
||||||
free(rpt);
|
free(rpt);
|
||||||
|
|
Loading…
Reference in New Issue