1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Avoid entering an endless loop while traversing the channel list

This commit is contained in:
LemonBoy 2016-04-19 15:29:16 +02:00
parent ed06e43ec8
commit 8f5e200551

View File

@ -168,7 +168,7 @@ static void print_netjoins(NETJOIN_SERVER_REC *server, const char *channel)
{ {
TEMP_PRINT_REC *temp; TEMP_PRINT_REC *temp;
GHashTable *channels; GHashTable *channels;
GSList *tmp, *next, *old; GSList *tmp, *tmp2, *next, *next2, *old;
g_return_if_fail(server != NULL); 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) { for (tmp = server->netjoins; tmp != NULL; tmp = next) {
NETJOIN_REC *rec = tmp->data; NETJOIN_REC *rec = tmp->data;
next = tmp->next; next = g_slist_next(tmp);
while (rec->now_channels != NULL) {
char *channel = rec->now_channels->data; for (tmp2 = rec->now_channels; tmp2 != NULL; tmp2 = next2) {
char *channel = tmp2->data;
char *realchannel = channel + 1; char *realchannel = channel + 1;
next2 = g_slist_next(tmp2);
if (channel != NULL && strcasecmp(realchannel, channel) != 0) if (channel != NULL && strcasecmp(realchannel, channel) != 0)
continue; continue;
@ -217,8 +220,8 @@ static void print_netjoins(NETJOIN_SERVER_REC *server, const char *channel)
g_free(data); g_free(data);
} }
rec->now_channels = /* drop tmp2 from the list */
g_slist_remove(rec->now_channels, channel); rec->now_channels = g_slist_delete_link(rec->now_channels, tmp2);
g_free(channel); g_free(channel);
} }