From 00c35d3f1d9081f6f260c4b4a9c7bb475ea29560 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 7 Feb 2014 14:11:17 +0200 Subject: [PATCH] android/avdtp: Fix passing NULL pointer to memcpy The patch fixes following clang warning: ... profiles/audio/avdtp.c:3293:2: warning: Null pointer passed as an argument to a 'nonnull' parameter memcpy(cap->data, data, length); ^ ~~~~ --- android/avdtp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/avdtp.c b/android/avdtp.c index ed95ad7e5..6f847ccb4 100644 --- a/android/avdtp.c +++ b/android/avdtp.c @@ -2939,10 +2939,15 @@ struct avdtp_service_capability *avdtp_service_cap_new(uint8_t category, if (category < AVDTP_MEDIA_TRANSPORT || category > AVDTP_DELAY_REPORTING) return NULL; + if (length > 0 && !data) + return NULL; + cap = g_malloc(sizeof(struct avdtp_service_capability) + length); cap->category = category; cap->length = length; - memcpy(cap->data, data, length); + + if (length > 0) + memcpy(cap->data, data, length); return cap; } -- 2.47.3