diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2015-08-27 13:43:57 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2015-08-28 10:37:04 +0300 |
commit | 60050fe469df1536466d1c6819670ce70ca92287 (patch) | |
tree | 2886a66e05ce385da0b5cb7e91cc8455444e57fc /profiles/audio/avrcp.c | |
parent | 18fe3cf498d046c2329e7ad75e585ed3b9ed1627 (diff) | |
download | bluez-60050fe469df1536466d1c6819670ce70ca92287.tar.gz |
audio/avrcp: Fix crash on RegisterNotification
When registering AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED there may not be
any player available causing a crash.
Diffstat (limited to 'profiles/audio/avrcp.c')
-rw-r--r-- | profiles/audio/avrcp.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index fa95bf9f2..5a1c8a391 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -1326,6 +1326,22 @@ static uint8_t player_get_status(struct avrcp_player *player) return play_status_to_val(value); } +static uint16_t player_get_id(struct avrcp_player *player) +{ + if (player == NULL) + return 0x0000; + + return player->id; +} + +static uint16_t player_get_uid_counter(struct avrcp_player *player) +{ + if (player == NULL) + return 0x0000; + + return player->uid_counter; +} + static uint8_t avrcp_handle_get_play_status(struct avrcp *session, struct avrcp_header *pdu, uint8_t transaction) @@ -1516,8 +1532,10 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, break; case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: len = 5; - memcpy(&pdu->params[1], &player->id, sizeof(uint16_t)); - memcpy(&pdu->params[3], &player->uid_counter, sizeof(uint16_t)); + memset(&pdu->params[1], player_get_id(player), + sizeof(uint16_t)); + memset(&pdu->params[3], player_get_uid_counter(player), + sizeof(uint16_t)); break; case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED: len = 1; |