From ff63982d4f46d2c671215dcf89cc1b4aa136ac56 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Wed, 6 Jun 2007 17:57:28 +0000 Subject: [PATCH] Don't add the same mask to the knockout list multiple times. This fixes bug #510. Note that #510 only happened if multiple bans were sent before the MODE came back and multiple unbans were sent before the MODE came back. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4544 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/irc-commands.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index 6a219433..e829eaa3 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -802,6 +802,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, char **nicklist, *spacenicks, *banmasks; void *free_arg; int timeleft; + GSList *ptr; CMD_IRC_SERVER(server); @@ -856,13 +857,20 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, if (*banmasks == '\0') g_free(banmasks); else { - /* create knockout record */ - rec = g_new(KNOCKOUT_REC, 1); + /* check if we already have this knockout */ + for (ptr = server->knockoutlist; ptr != NULL; ptr = ptr->next) { + rec = ptr->data; + if (channel == rec->channel && + !strcmp(rec->ban, banmasks)) + break; + } + if (ptr == NULL) { + rec = g_new(KNOCKOUT_REC, 1); + rec->channel = channel; + rec->ban = banmasks; + server->knockoutlist = g_slist_append(server->knockoutlist, rec); + } rec->unban_time = time(NULL)+timeleft/1000; - rec->channel = channel; - rec->ban = banmasks; - - server->knockoutlist = g_slist_append(server->knockoutlist, rec); } cmd_params_free(free_arg);