Skip to content

Commit

Permalink
Don't try to memcpy() to a NULL destination. (#637)
Browse files Browse the repository at this point in the history
This function is called with a literal NULL for that pointer later in
the file.
  • Loading branch information
icculus committed Nov 12, 2023
1 parent 86b056f commit eea8cac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mac/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,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);
Expand Down

0 comments on commit eea8cac

Please sign in to comment.