[PATCH] android/avrcp: Fix clang warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

Check len before memcpy(). Fixes:
...
android/avrcp-lib.c:885:3: warning: Null pointer passed as an argument
to a 'nonnull' parameter
                memcpy(&ptr[4], text[i], len);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
---
 android/avrcp-lib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index a7a819d..ea4bad9 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -889,7 +889,10 @@ int avrcp_get_player_attribute_text_rsp(struct avrcp *session,
 		ptr[0] = attrs[i];
 		bt_put_be16(AVRCP_CHARSET_UTF8, &ptr[1]);
 		ptr[3] = len;
-		memcpy(&ptr[4], text[i], len);
+
+		if (len)
+			memcpy(&ptr[4], text[i], len);
+
 		ptr += 4 + len;
 		length += 4 + len;
 	}
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux