mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-25 18:53:02 +01:00
Fix possible null dereference
game invite info needs to be set after calloc in case it fails
This commit is contained in:
parent
2946e0dc56
commit
3030cda47e
10
src/chat.c
10
src/chat.c
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user