diff --git a/toxcore/group_chats.c b/toxcore/group_chats.c index b610e9a5..1ec8ede5 100644 --- a/toxcore/group_chats.c +++ b/toxcore/group_chats.c @@ -787,7 +787,10 @@ static void del_dead_peers(Group_Chat *chat) delpeer(chat, i); } - if (chat->group != NULL && chat->group[i].deleted) { + if (chat->group == NULL || i >= chat->numpeers) + break; + + if (chat->group[i].deleted) { if (is_timeout(chat->group[i].deleted_time, DEL_PEER_DELAY)) delpeer(chat, i); }