summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWouter Coekaerts <coekie@irssi.org>2005-03-06 18:47:05 +0000
committercoekie <coekie@dbcabf3a-b0e7-0310-adc4-f8d773084564>2005-03-06 18:47:05 +0000
commite159d8b2f05a57f1e8fa35595f4899b56e06503c (patch)
treea9b1c23ea4fca113091ad8e0232a7cb7e58ad0a8 /src
parentbd8712dde1b4d9ad2ee261811bf41163e28f02cd (diff)
downloadirssi-e159d8b2f05a57f1e8fa35595f4899b56e06503c.zip
Fix memleak in dcc get, by Toby Peterson (Bug 214)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3716 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/irc/dcc/dcc-get.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/irc/dcc/dcc-get.c b/src/irc/dcc/dcc-get.c
index e99d3cf6..eb871149 100644
--- a/src/irc/dcc/dcc-get.c
+++ b/src/irc/dcc/dcc-get.c
@@ -375,6 +375,22 @@ int get_file_params_count(char **params, int paramcount)
return best;
}
+char *get_file_name(char **params, int fileparams)
+{
+ GString *out = g_string_new(params[0]);
+ char *ret;
+ int pos;
+
+ for (pos = 1; pos < fileparams; pos++) {
+ out = g_string_append(out, " ");
+ out = g_string_append(out, params[pos]);
+ }
+
+ ret = out->str;
+ g_string_free(out, FALSE);
+ return ret;
+}
+
/* CTCP: DCC SEND */
static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr,
@@ -405,7 +421,7 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
fileparams = get_file_params_count(params, paramcount);
- address = params[fileparams];
+ address = g_strdup(params[fileparams]);
dcc_str2ip(address, &ip);
port = atoi(params[fileparams+1]);
size = str_to_uofft(params[fileparams+2]);
@@ -416,8 +432,7 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
passive = TRUE;
}
- params[fileparams] = NULL;
- fname = g_strjoinv(" ", params);
+ fname = get_file_name(params, fileparams);
g_strfreev(params);
len = strlen(fname);
@@ -452,12 +467,14 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
/* This new signal is added to let us invoke
dcc_send_connect() which is found in dcc-send.c */
signal_emit("dcc reply send pasv", 1, temp_dcc);
+ g_free(address);
g_free(fname);
return;
} else if (temp_dcc != NULL && p_id != temp_dcc->pasv_id) {
/* IDs don't match... remove the old DCC SEND and
return */
dcc_destroy(DCC(temp_dcc));
+ g_free(address);
g_free(fname);
return;
}
@@ -486,6 +503,7 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
signal_emit("dcc request", 2, dcc, addr);
+ g_free(address);
g_free(fname);
}