diff options
author | Nei <ailin.nemui@gmail.com> | 2017-07-05 14:46:42 +0000 |
---|---|---|
committer | Nei <ailin.nemui@gmail.com> | 2017-07-05 14:46:42 +0000 |
commit | f67e7669341bfe2962623a3e9bbb46f9cd9d60e7 (patch) | |
tree | 0d00b367c799581fea82cbe89f27d377736559df | |
parent | fc3615120d7a7f48afa012159acd3dc224ecf4e3 (diff) | |
parent | 73b851c39c11d01199e6c040749fb20e468f6c8d (diff) | |
download | irssi-f67e7669341bfe2962623a3e9bbb46f9cd9d60e7.zip |
Merge branch 'fix-11' into 'security'
Correct GHashTable usage
See merge request !16
-rw-r--r-- | src/core/nicklist.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/nicklist.c b/src/core/nicklist.c index 54dfb5fb..0bc88ab8 100644 --- a/src/core/nicklist.c +++ b/src/core/nicklist.c @@ -54,23 +54,26 @@ static void nick_hash_add(CHANNEL_REC *channel, NICK_REC *nick) static void nick_hash_remove(CHANNEL_REC *channel, NICK_REC *nick) { - NICK_REC *list; + NICK_REC *list, *newlist; list = g_hash_table_lookup(channel->nicks, nick->nick); if (list == NULL) return; - if (list == nick || list->next == NULL) { - g_hash_table_remove(channel->nicks, nick->nick); - if (list->next != NULL) { - g_hash_table_insert(channel->nicks, nick->next->nick, - nick->next); - } + if (list == nick) { + newlist = nick->next; } else { + newlist = list; while (list->next != nick) list = list->next; list->next = nick->next; } + + g_hash_table_remove(channel->nicks, nick->nick); + if (newlist != NULL) { + g_hash_table_insert(channel->nicks, newlist->nick, + newlist); + } } /* Add new nick to list */ |