mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed possible segfault.
This commit is contained in:
parent
ba000a2424
commit
18c98eb87d
|
@ -234,8 +234,13 @@ static int delpeer(Group_Chat *chat, uint8_t *client_id)
|
|||
if (id_equal(chat->group[i].client_id, client_id)) {
|
||||
--chat->numpeers;
|
||||
|
||||
if (chat->numpeers == 0) {
|
||||
free(chat->group);
|
||||
chat->group = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (chat->numpeers != i)
|
||||
id_copy(chat->group[i].client_id, chat->group[chat->numpeers].client_id);
|
||||
memcpy(&chat->group[i], &chat->group[chat->numpeers], sizeof(Group_Peer));
|
||||
|
||||
temp = realloc(chat->group, sizeof(Group_Peer) * (chat->numpeers));
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user