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:
Alan Ott
2010-11-16 22:49:04 -05:00
parent ff8cd18282
commit 2b5e896370
+2 -1
View File
@@ -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);