From 6e5a5498dbae771a4ab58b8b194173c3f93219e4 Mon Sep 17 00:00:00 2001 From: Alexandre Colucci Date: Tue, 27 Jun 2017 14:33:38 +0200 Subject: [PATCH] Fix a possible NULL pointer dereference which would lead to a crash --- mac/hid.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mac/hid.c b/mac/hid.c index e0756a15..eb045587 100644 --- a/mac/hid.c +++ b/mac/hid.c @@ -798,6 +798,11 @@ static int return_data(hid_device *dev, unsigned char *data, size_t length) /* Copy the data out of the linked list item (rpt) into the return buffer (data), and delete the liked list item. */ struct input_report *rpt = dev->input_reports; + if(rpt == NULL) { + errno = EINVAL; + return 0; + } + size_t len = (length < rpt->len)? length: rpt->len; memcpy(data, rpt->data, len); dev->input_reports = rpt->next;