diff options
author | LemonBoy <thatlemon@gmail.com> | 2016-04-19 15:29:16 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2016-06-26 21:45:03 +0200 |
commit | 8f5e2005516023f5c96cf95ac5e9f917bda33172 (patch) | |
tree | fc976e98ace3e8a245047dfc08985ae1ae7e642b | |
parent | ed06e43ec816eb4b9f1a736ecba6802a586887a8 (diff) | |
download | irssi-8f5e2005516023f5c96cf95ac5e9f917bda33172.zip |
Avoid entering an endless loop while traversing the channel list
-rw-r--r-- | src/fe-common/irc/fe-netjoin.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/fe-common/irc/fe-netjoin.c b/src/fe-common/irc/fe-netjoin.c index 6e54b313..807a4345 100644 --- a/src/fe-common/irc/fe-netjoin.c +++ b/src/fe-common/irc/fe-netjoin.c @@ -168,7 +168,7 @@ static void print_netjoins(NETJOIN_SERVER_REC *server, const char *channel) { TEMP_PRINT_REC *temp; GHashTable *channels; - GSList *tmp, *next, *old; + GSList *tmp, *tmp2, *next, *next2, *old; g_return_if_fail(server != NULL); @@ -181,11 +181,14 @@ static void print_netjoins(NETJOIN_SERVER_REC *server, const char *channel) for (tmp = server->netjoins; tmp != NULL; tmp = next) { NETJOIN_REC *rec = tmp->data; - next = tmp->next; - while (rec->now_channels != NULL) { - char *channel = rec->now_channels->data; + next = g_slist_next(tmp); + + for (tmp2 = rec->now_channels; tmp2 != NULL; tmp2 = next2) { + char *channel = tmp2->data; char *realchannel = channel + 1; + next2 = g_slist_next(tmp2); + if (channel != NULL && strcasecmp(realchannel, channel) != 0) continue; @@ -217,8 +220,8 @@ static void print_netjoins(NETJOIN_SERVER_REC *server, const char *channel) g_free(data); } - rec->now_channels = - g_slist_remove(rec->now_channels, channel); + /* drop tmp2 from the list */ + rec->now_channels = g_slist_delete_link(rec->now_channels, tmp2); g_free(channel); } |