summaryrefslogtreecommitdiff
path: root/src/irc/core
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2016-03-18 22:50:00 +0100
committerLemonBoy <thatlemon@gmail.com>2016-03-19 12:11:53 +0100
commitf31d37a85271e0196aeefd409f0ab361ffd8c2ff (patch)
tree7cf6fe67c667c815d9295ba30b42ff0a4d815981 /src/irc/core
parentf6c2805b91161a01378c9bbe853521c08d460c60 (diff)
downloadirssi-f31d37a85271e0196aeefd409f0ab361ffd8c2ff.zip
Make ischannel_func return false for empty strings
Diffstat (limited to 'src/irc/core')
-rw-r--r--src/irc/core/irc-servers.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c
index d6fb8018..1df95f70 100644
--- a/src/irc/core/irc-servers.c
+++ b/src/irc/core/irc-servers.c
@@ -78,17 +78,23 @@ static int ischannel_func(SERVER_REC *server, const char *data)
IRC_SERVER_REC *irc_server = (IRC_SERVER_REC *) server;
char *chantypes, *statusmsg;
+ g_return_val_if_fail(data != NULL, FALSE);
+
+ /* empty string is no channel */
+ if (*data == '\0')
+ return FALSE;
+
chantypes = g_hash_table_lookup(irc_server->isupport, "chantypes");
if (chantypes == NULL)
chantypes = "#&!+"; /* normal, local, secure, modeless */
statusmsg = g_hash_table_lookup(irc_server->isupport, "statusmsg");
- if (statusmsg != NULL) {
- while (strchr(statusmsg, *data) != NULL)
- data++;
- }
+ if (statusmsg != NULL)
+ data += strspn(data, statusmsg);
- return strchr(chantypes, *data) != NULL;
+ /* strchr(3) considers the trailing NUL as part of the string, make sure
+ * we didn't advance too much. */
+ return *data != '\0' && strchr(chantypes, *data) != NULL;
}
static char **split_line(const SERVER_REC *server, const char *line,