From 05cfbaf9d5b08f77adadf6d955c04f76c348aae7 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 29 Jul 2000 17:59:45 +0000 Subject: [PATCH] /OP, /DEOP, /VOICE and /DEVOICE without any parameters didn't work right git-svn-id: http://svn.irssi.org/repos/irssi/trunk@549 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/modes.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/irc/core/modes.c b/src/irc/core/modes.c index 3e8df891..199aa5fe 100644 --- a/src/irc/core/modes.c +++ b/src/irc/core/modes.c @@ -374,6 +374,10 @@ static char *get_nicks(WI_IRC_REC *item, const char *data, int op, int voice) GSList *nicks, *tmp; char **matches, **match, *ret; + g_return_val_if_fail(item != NULL, NULL); + g_return_val_if_fail(data != NULL, NULL); + if (*data == '\0') return NULL; + str = g_string_new(NULL); matches = g_strsplit(data, " ", -1); for (match = matches; *match != NULL; match++) { @@ -415,9 +419,9 @@ static void cmd_op(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item) return; nicks = get_nicks(item, data, 0, -1); - if (*nicks != '\0') + if (nicks != NULL && *nicks != '\0') channel_set_singlemode(server, item->name, nicks, "+o"); - g_free(nicks); + g_free_not_null(nicks); } /* SYNTAX: DEOP */ @@ -429,9 +433,9 @@ static void cmd_deop(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item) return; nicks = get_nicks(item, data, 1, -1); - if (*nicks != '\0') + if (nicks != NULL && *nicks != '\0') channel_set_singlemode(server, item->name, nicks, "-o"); - g_free(nicks); + g_free_not_null(nicks); } /* SYNTAX: VOICE */ @@ -443,9 +447,9 @@ static void cmd_voice(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item return; nicks = get_nicks(item, data, 0, 0); - if (*nicks != '\0') + if (nicks != NULL && *nicks != '\0') channel_set_singlemode(server, item->name, nicks, "+v"); - g_free(nicks); + g_free_not_null(nicks); } /* SYNTAX: DEVOICE */ @@ -457,9 +461,9 @@ static void cmd_devoice(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *it return; nicks = get_nicks(item, data, 0, 1); - if (*nicks != '\0') + if (nicks != NULL && *nicks != '\0') channel_set_singlemode(server, item->name, nicks, "-v"); - g_free(nicks); + g_free_not_null(nicks); } /* SYNTAX: MODE | [ []] */