mirror of
https://github.com/RPCS3/hidapi.git
synced 2026-07-21 00:45:21 -04:00
Check for NULL before calling memcpy().
Although it works without problem, it is technically illegal to call memcpy() with a destination of NULL, even if size is zero. Reported-by: Ludovic Rousseau <ludovic.rousseau@gmail.com>
This commit is contained in:
+2
-1
@@ -706,7 +706,8 @@ 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 (len > 0)
|
||||
memcpy(data, rpt->data, len);
|
||||
dev->input_reports = rpt->next;
|
||||
free(rpt->data);
|
||||
free(rpt);
|
||||
|
||||
Reference in New Issue
Block a user