better error checks for failure conditions (based on Puneet Pawaia's reports)
This commit is contained in:
parent
87c7f403a9
commit
28497e7ee4
16
lib/ftp.c
16
lib/ftp.c
@ -1720,12 +1720,14 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn)
|
|||||||
{
|
{
|
||||||
struct FTP *ftp= conn->proto.ftp;
|
struct FTP *ftp= conn->proto.ftp;
|
||||||
|
|
||||||
if(ftp->user)
|
/* The FTP session may or may not have been allocated/setup at this point! */
|
||||||
free(ftp->user);
|
if(ftp) {
|
||||||
if(ftp->passwd)
|
if(ftp->user)
|
||||||
free(ftp->passwd);
|
free(ftp->user);
|
||||||
if(ftp->entrypath)
|
if(ftp->passwd)
|
||||||
free(ftp->entrypath);
|
free(ftp->passwd);
|
||||||
|
if(ftp->entrypath)
|
||||||
|
free(ftp->entrypath);
|
||||||
|
}
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
@ -955,7 +955,7 @@ CURLcode Curl_perform(CURL *curl)
|
|||||||
|
|
||||||
} while(1); /* loop if Location: */
|
} while(1); /* loop if Location: */
|
||||||
|
|
||||||
if(conn->newurl) {
|
if((CURLE_OK == res) && conn->newurl) {
|
||||||
free(conn->newurl);
|
free(conn->newurl);
|
||||||
conn->newurl = NULL;
|
conn->newurl = NULL;
|
||||||
}
|
}
|
||||||
|
@ -816,6 +816,9 @@ CURLcode Curl_disconnect(struct connectdata *conn)
|
|||||||
free(conn->hostent_buf);
|
free(conn->hostent_buf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(conn->newurl)
|
||||||
|
free(conn->newurl);
|
||||||
|
|
||||||
if(conn->path) /* the URL path part */
|
if(conn->path) /* the URL path part */
|
||||||
free(conn->path);
|
free(conn->path);
|
||||||
|
|
||||||
@ -2147,8 +2150,10 @@ CURLcode Curl_connect(struct UrlData *data,
|
|||||||
/* We're not allowed to return failure with memory left allocated
|
/* We're not allowed to return failure with memory left allocated
|
||||||
in the connectdata struct, free those here */
|
in the connectdata struct, free those here */
|
||||||
conn = (struct connectdata *)*in_connect;
|
conn = (struct connectdata *)*in_connect;
|
||||||
if(conn)
|
if(conn) {
|
||||||
Curl_disconnect(conn); /* close the connection */
|
Curl_disconnect(conn); /* close the connection */
|
||||||
|
*in_connect = NULL; /* return a NULL */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user