aboutsummaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-08-31 18:14:38 +0200
committerYang Tse <yangsita@gmail.com>2011-08-31 18:14:38 +0200
commit0b018a0a053cf888014edc66b5042d3eb2694571 (patch)
tree0e452ed3bc08c47019d05c00a0c6e0e0dec6e29f /lib/ftp.c
parentd20408e8161a55b8408a47a33d89ee8d37b6e146 (diff)
ftp.c: fix some leaks torture tests detected 2011-08-30 - follow-up
follow-up for commit c06de200
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 538873a10..a6362b24c 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2610,12 +2610,6 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
store++;
ptr++;
}
- if(ftpc->entrypath)
- free(ftpc->entrypath);
- ftpc->entrypath =dir; /* remember this */
- infof(data, "Entry path is '%s'\n", ftpc->entrypath);
- /* also save it where getinfo can access it: */
- data->state.most_recent_ftp_entrypath = ftpc->entrypath;
/* If the path name does not look like an absolute path (i.e.: it
does not start with a '/'), we probably need some server-dependent
@@ -2629,18 +2623,27 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if the path name looks strange to minimize overhead on other
systems. */
- if(!ftpc->server_os && ftpc->entrypath[0] != '/') {
+ if(!ftpc->server_os && dir[0] != '/') {
result = Curl_pp_sendf(&ftpc->pp, "SYST", NULL);
if(result != CURLE_OK) {
- free(ftpc->entrypath);
- ftpc->entrypath = NULL;
- data->state.most_recent_ftp_entrypath = NULL;
+ free(dir);
return result;
}
+ Curl_safefree(ftpc->entrypath);
+ ftpc->entrypath = dir; /* remember this */
+ infof(data, "Entry path is '%s'\n", ftpc->entrypath);
+ /* also save it where getinfo can access it: */
+ data->state.most_recent_ftp_entrypath = ftpc->entrypath;
state(conn, FTP_SYST);
break;
}
+
+ Curl_safefree(ftpc->entrypath);
+ ftpc->entrypath = dir; /* remember this */
+ infof(data, "Entry path is '%s'\n", ftpc->entrypath);
+ /* also save it where getinfo can access it: */
+ data->state.most_recent_ftp_entrypath = ftpc->entrypath;
}
else {
/* couldn't get the path */
@@ -2670,25 +2673,28 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
for(store = os; *ptr && *ptr != ' ';)
*store++ = *ptr++;
*store = '\0'; /* zero terminate */
- Curl_safefree(ftpc->server_os);
- ftpc->server_os = os;
/* Check for special servers here. */
- if(strequal(ftpc->server_os, "OS/400")) {
+ if(strequal(os, "OS/400")) {
/* Force OS400 name format 1. */
result = Curl_pp_sendf(&ftpc->pp, "SITE NAMEFMT 1", NULL);
if(result != CURLE_OK) {
- free(ftpc->server_os);
- ftpc->server_os = NULL;
+ free(os);
return result;
}
+ /* remember target server OS */
+ Curl_safefree(ftpc->server_os);
+ ftpc->server_os = os;
state(conn, FTP_NAMEFMT);
break;
}
- else {
- /* Nothing special for the target server. */
- }
+ else {
+ /* Nothing special for the target server. */
+ /* remember target server OS */
+ Curl_safefree(ftpc->server_os);
+ ftpc->server_os = os;
+ }
}
else {
/* Cannot identify server OS. Continue anyway and cross fingers. */