summaryrefslogtreecommitdiff
path: root/src/irc/dcc/dcc-chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc/dcc/dcc-chat.c')
-rw-r--r--src/irc/dcc/dcc-chat.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/irc/dcc/dcc-chat.c b/src/irc/dcc/dcc-chat.c
index 8ee4decd..88c577f7 100644
--- a/src/irc/dcc/dcc-chat.c
+++ b/src/irc/dcc/dcc-chat.c
@@ -66,6 +66,13 @@ CHAT_DCC_REC *dcc_chat_create(IRC_SERVER_REC *server,
dcc->id = dcc_chat_get_new_id(nick);
dcc_init_rec(DCC(dcc), server, chat, nick, arg);
+ if (dcc->module_data == NULL) {
+ /* failed to successfully init; TODO: change init_rec API */
+ g_free(dcc->id);
+ g_free(dcc);
+ return NULL;
+ }
+
return dcc;
}
@@ -191,7 +198,7 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
return;
/* handle only DCC messages */
- if (strcmp(target, "*") == 0)
+ if (g_strcmp0(target, "*") == 0)
dcc = item_get_dcc(item);
else if (*target == '=')
dcc = dcc_chat_find_id(target+1);
@@ -471,6 +478,7 @@ static void cmd_dcc_chat(const char *data, IRC_SERVER_REC *server)
/* We are accepting a passive DCC CHAT. */
dcc_chat_passive(dcc);
}
+ cmd_params_free(free_arg);
return;
}
@@ -485,6 +493,11 @@ static void cmd_dcc_chat(const char *data, IRC_SERVER_REC *server)
cmd_param_error(CMDERR_NOT_CONNECTED);
dcc = dcc_chat_create(server, NULL, nick, "chat");
+ if (dcc == NULL) {
+ cmd_params_free(free_arg);
+ g_warn_if_reached();
+ return;
+ }
if (g_hash_table_lookup(optlist, "passive") == NULL) {
/* Standard DCC CHAT... let's listen for incoming connections */
@@ -619,13 +632,16 @@ static void ctcp_msg_dcc_chat(IRC_SERVER_REC *server, const char *data,
/* CHAT <unused> <address> <port> */
/* CHAT <unused> <address> 0 <id> (DCC CHAT passive protocol) */
params = g_strsplit(data, " ", -1);
- paramcount = strarray_length(params);
+ paramcount = g_strv_length(params);
if (paramcount < 3) {
g_strfreev(params);
return;
}
- passive = paramcount == 4 && strcmp(params[2], "0") == 0;
+ passive = paramcount == 4 && g_strcmp0(params[2], "0") == 0;
+
+ if (nick == NULL)
+ nick = "";
dcc = DCC_CHAT(dcc_find_request(DCC_CHAT_TYPE, nick, NULL));
if (dcc != NULL) {
@@ -658,6 +674,11 @@ static void ctcp_msg_dcc_chat(IRC_SERVER_REC *server, const char *data,
}
dcc = dcc_chat_create(server, chat, nick, params[0]);
+ if (dcc == NULL) {
+ g_strfreev(params);
+ g_warn_if_reached();
+ return;
+ }
dcc->target = g_strdup(target);
dcc->port = atoi(params[2]);