From 065d80716b9515c77b15f186d5e14160885d9ae5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 6 Nov 2023 13:48:07 -0500 Subject: [PATCH] hidapi: Avoid memcpy'ing to NULL. (This fix was originally from @themightyoarfish on GitHub. Thanks!) Fixes #8428. Reference PR #8431. (cherry picked from commit c6d9fb1ad71462bc844c6ca41e2ac7fe7cec3883) --- src/hidapi/mac/hid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hidapi/mac/hid.c b/src/hidapi/mac/hid.c index c6541682c..bbb5c625d 100644 --- a/src/hidapi/mac/hid.c +++ b/src/hidapi/mac/hid.c @@ -957,7 +957,9 @@ static int return_data(hid_device *dev, unsigned char *data, size_t length) size_t len = 0; if (rpt != NULL) { 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);