]> PatchyGit - patchyircd.git/commitdiff
fix channel member leak when using NICK
authorEgor <egor@patchysicp.xyz>
Thu, 12 May 2022 07:33:17 +0000 (10:33 +0300)
committerEgor <egor@patchysicp.xyz>
Thu, 12 May 2022 07:35:35 +0000 (10:35 +0300)
irc.c

diff --git a/irc.c b/irc.c
index 7897217..60dbc53 100644 (file)
--- 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);
        }