From 3d388a0a9617036eccda8d5df9c077207431ba1c Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 16 Oct 2022 21:29:49 +0200 Subject: [PATCH] Don't pass a NULL pointer to memcpy The memcpy and related functions expects a valid pointer, even if the size is zero. Most libc implementations will handle a NULL pointer just fine, but that's not guaranteed. Simply skip the call when there is nothing to copy. --- src/deepsix_excursion.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/deepsix_excursion.c b/src/deepsix_excursion.c index 378e20f..53135de 100644 --- a/src/deepsix_excursion.c +++ b/src/deepsix_excursion.c @@ -163,7 +163,9 @@ deepsix_excursion_recv (deepsix_excursion_device_t *device, unsigned char grp, u return DC_STATUS_PROTOCOL; } - memcpy(data, packet + 4, len); + if (len) { + memcpy(data, packet + 4, len); + } if (actual) *actual = len;