From 2b5e8963708cccd091065bf78fa27539d076079c Mon Sep 17 00:00:00 2001 From: Alan Ott Date: Tue, 16 Nov 2010 22:49:04 -0500 Subject: [PATCH] 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 --- linux/hid-libusb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux/hid-libusb.c b/linux/hid-libusb.c index 6cfa2b2..03784bc 100644 --- a/linux/hid-libusb.c +++ b/linux/hid-libusb.c @@ -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);