1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-25 16:13:01 +01:00

Fix possible null dereference

game invite info needs to be set after calloc in case it fails
This commit is contained in:
jfreegman 2021-12-10 13:44:33 -05:00
parent 2946e0dc56
commit 3030cda47e
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

@ -798,12 +798,7 @@ void chat_onGameInvite(ToxWindow *self, Tox *m, uint32_t friend_number, const ui
return; return;
} }
Friends.list[friend_number].game_invite.type = type;
Friends.list[friend_number].game_invite.id = id;
Friends.list[friend_number].game_invite.pending = true;
uint32_t data_length = length - GAME_PACKET_HEADER_SIZE; uint32_t data_length = length - GAME_PACKET_HEADER_SIZE;
Friends.list[friend_number].game_invite.data_length = data_length;
if (data_length > 0) { if (data_length > 0) {
free(Friends.list[friend_number].game_invite.data); free(Friends.list[friend_number].game_invite.data);
@ -818,6 +813,11 @@ void chat_onGameInvite(ToxWindow *self, Tox *m, uint32_t friend_number, const ui
Friends.list[friend_number].game_invite.data = buf; Friends.list[friend_number].game_invite.data = buf;
} }
Friends.list[friend_number].game_invite.type = type;
Friends.list[friend_number].game_invite.id = id;
Friends.list[friend_number].game_invite.pending = true;
Friends.list[friend_number].game_invite.data_length = data_length;
char name[TOX_MAX_NAME_LENGTH]; char name[TOX_MAX_NAME_LENGTH];
get_nick_truncate(m, name, friend_number); get_nick_truncate(m, name, friend_number);