summaryrefslogtreecommitdiff
path: root/src/core/chat-commands.c
diff options
context:
space:
mode:
authorJoseph Bisch <joseph.bisch@gmail.com>2017-10-16 16:21:10 -0400
committerailin-nemui <ailin-nemui@users.noreply.github.com>2017-10-20 15:22:32 +0200
commit73d7b9d7753d35c63f24defe6d26c7c06ffa3cce (patch)
tree54ca5d218d96d0081c3fc02ec059da99770ca3cc /src/core/chat-commands.c
parent28d0b8c74602db0474c78ccbe17ae1ba03fcf665 (diff)
downloadirssi-73d7b9d7753d35c63f24defe6d26c7c06ffa3cce.zip
Don't proceed with cmd_msg if there was an error splitting msg
There may be cases (such as if target or server->nick is very long) where the split_message function returns NULL, indicating an error. To avoid a potential segfault, we now check to see if splitmsgs is NULL.
Diffstat (limited to 'src/core/chat-commands.c')
-rw-r--r--src/core/chat-commands.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index d5a133f8..77f02aa2 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -404,7 +404,10 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
else
splitmsgs = singlemsg;
- while ((m = splitmsgs[n++])) {
+ /* splitmsgs may be NULL if there was an error */
+ g_warn_if_fail(splitmsgs != NULL);
+
+ while (splitmsgs && (m = splitmsgs[n++])) {
signal_emit("server sendmsg", 4, server, target, m,
GINT_TO_POINTER(target_type));
signal_emit(target_type == SEND_TARGET_CHANNEL ?