From: Andrei Emeltchenko <[email protected]>
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