From: Egor Date: Thu, 12 May 2022 07:33:17 +0000 (+0300) Subject: fix channel member leak when using NICK X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=c0f6c8edaf6bbfa455fdd58eef7bbd51d36b72bb;p=patchyircd.git fix channel member leak when using NICK --- 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); }