*/
#define CURL_FTP_HTTPSTYLE_HEAD 1
-static void freedirs(struct connectdata *conn)
+static void freedirs(struct ftp_conn *ftpc)
{
- struct ftp_conn *ftpc = &conn->proto.ftpc;
-
int i;
if(ftpc->dirs) {
for (i=0; i < ftpc->dirdepth; i++){
}
}
/* free the dir tree and file parts */
- freedirs(conn);
+ freedirs(ftpc);
#if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)
Curl_sec_fflush_fd(conn, conn->sock[SECONDARYSOCKET]);
*/
/* The FTP session may or may not have been allocated/setup at this point! */
- /* FIXME: checking for conn->data->reqdata.proto.ftp is not correct here,
- * the reqdata structure could be used by another connection already */
- if(conn->data->reqdata.proto.ftp) {
- (void)ftp_quit(conn); /* ignore errors on the QUIT */
-
- if(ftpc->entrypath) {
- struct SessionHandle *data = conn->data;
- if (data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
- data->state.most_recent_ftp_entrypath = NULL;
- }
- free(ftpc->entrypath);
- ftpc->entrypath = NULL;
- }
- if(ftpc->cache) {
- free(ftpc->cache);
- ftpc->cache = NULL;
- }
- freedirs(conn);
- if(ftpc->prevpath) {
- free(ftpc->prevpath);
- ftpc->prevpath = NULL;
+ (void)ftp_quit(conn); /* ignore errors on the QUIT */
+
+ if(ftpc->entrypath) {
+ struct SessionHandle *data = conn->data;
+ if (data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
+ data->state.most_recent_ftp_entrypath = NULL;
}
+ free(ftpc->entrypath);
+ ftpc->entrypath = NULL;
+ }
+ if(ftpc->cache) {
+ free(ftpc->cache);
+ ftpc->cache = NULL;
+ }
+ freedirs(ftpc);
+ if(ftpc->prevpath) {
+ free(ftpc->prevpath);
+ ftpc->prevpath = NULL;
}
+
return CURLE_OK;
}
slash_pos?(int)(slash_pos-cur_pos):1,
NULL);
if(!ftpc->dirs[0]) {
- freedirs(conn);
+ freedirs(ftpc);
return CURLE_OUT_OF_MEMORY;
}
ftpc->dirdepth = 1; /* we consider it to be a single dir */
curl_easy_unescape(conn->data, cur_pos - absolute_dir, len, NULL);
if (!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
failf(data, "no memory");
- freedirs(conn);
+ freedirs(ftpc);
return CURLE_OUT_OF_MEMORY;
}
if (isBadFtpString(ftpc->dirs[ftpc->dirdepth])) {
free(ftpc->dirs[ftpc->dirdepth]);
- freedirs(conn);
+ freedirs(ftpc);
return CURLE_URL_MALFORMAT;
}
}
ftpc->diralloc *= 2; /* double the size each time */
bigger = realloc(ftpc->dirs, ftpc->diralloc * sizeof(ftpc->dirs[0]));
if(!bigger) {
- freedirs(conn);
+ freedirs(ftpc);
return CURLE_OUT_OF_MEMORY;
}
ftpc->dirs = (char **)bigger;
if(ftpc->file && *ftpc->file) {
ftpc->file = curl_easy_unescape(conn->data, ftpc->file, 0, NULL);
if(NULL == ftpc->file) {
- freedirs(conn);
+ freedirs(ftpc);
failf(data, "no memory");
return CURLE_OUT_OF_MEMORY;
}
if (isBadFtpString(ftpc->file)) {
- freedirs(conn);
+ freedirs(ftpc);
return CURLE_URL_MALFORMAT;
}
}
strings */
char *path = curl_easy_unescape(conn->data, data->reqdata.path, 0, NULL);
if(!path) {
- freedirs(conn);
+ freedirs(ftpc);
return CURLE_OUT_OF_MEMORY;
}
return result;
}
else
- freedirs(conn);
+ freedirs(ftpc);
return result;
}