Diff between 47f6853fa28381b852490823e01305746a49c89d and 00c35d3f1d9081f6f260c4b4a9c7bb475ea29560

Changed Files

File Additions Deletions Status
android/avdtp.c +6 -1 modified

Full Patch

diff --git a/android/avdtp.c b/android/avdtp.c
index ed95ad7..6f847cc 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;
 }