Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly deallocate frozen peers #2058

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions toxcore/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ static int32_t create_group_chat(Group_Chats *g_c)
return -1;
}

non_null()
static void wipe_group_c(Group_c *g)
{
free(g->frozen);
free(g->group);
crypto_memzero(g, sizeof(Group_c));
}

/** Wipe a groupchat.
*
Expand All @@ -139,12 +146,13 @@ static int32_t create_group_chat(Group_Chats *g_c)
non_null()
static bool wipe_group_chat(Group_Chats *g_c, uint32_t groupnumber)
{
if (!is_groupnumber_valid(g_c, groupnumber)) {
if (groupnumber >= g_c->num_chats || g_c->chats == nullptr) {
return false;
}

wipe_group_c(&g_c->chats[groupnumber]);

uint16_t i;
crypto_memzero(&g_c->chats[groupnumber], sizeof(Group_c));

for (i = g_c->num_chats; i != 0; --i) {
if (g_c->chats[i - 1].status != GROUPCHAT_STATUS_NONE) {
Expand Down Expand Up @@ -1208,9 +1216,6 @@ int del_groupchat(Group_Chats *g_c, uint32_t groupnumber, bool leave_permanently
}
}

free(g->group);
free(g->frozen);

if (g->group_on_delete != nullptr) {
g->group_on_delete(g->object, groupnumber);
}
Expand Down