From c0f6c8edaf6bbfa455fdd58eef7bbd51d36b72bb Mon Sep 17 00:00:00 2001 From: Egor Date: Thu, 12 May 2022 10:33:17 +0300 Subject: [PATCH] fix channel member leak when using NICK --- irc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/irc.c b/irc.c index 7897217..60dbc53 100644 --- a/irc.c +++ b/irc.c @@ -1085,6 +1085,20 @@ void setNick(struct client_data *client, char* nickname) { sendbuf(client); sendbuf_visible(client); trie_set(&client_map, client->key, NULL, NULL); + struct trie_find *f = NULL; + if (trie_findfirst(&f, &client->channels) == 1) + do { + struct channel *chan = f->n->value; + trie_set(&chan->members, client->key, NULL, NULL); + trie_set(&chan->members, key, client, NULL); + void *old; + trie_set(&chan->o, client->key, NULL, &old); + if (old) + trie_set(&chan->o, key, client, NULL); + trie_set(&chan->v, client->key, NULL, &old); + if (old) + trie_set(&chan->v, key, client, NULL); + } while(trie_findnext(&f) == 1); free(client->nick); free(client->key); } -- 2.56.0