summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-04-03 10:20:23 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-04-03 10:20:23 +0000
commit28497e7ee40e8e2bf3c50f20c311bf9abff34ea6 (patch)
tree85bbe960cfe2dedad25122fab285a7d876ee55b1
parent87c7f403a9a6d1f57bc50a322ce506775ca25395 (diff)
downloadgnurl-28497e7ee40e8e2bf3c50f20c311bf9abff34ea6.tar.gz
gnurl-28497e7ee40e8e2bf3c50f20c311bf9abff34ea6.tar.bz2
gnurl-28497e7ee40e8e2bf3c50f20c311bf9abff34ea6.zip
better error checks for failure conditions (based on Puneet Pawaia's reports)
-rw-r--r--lib/ftp.c16
-rw-r--r--lib/transfer.c2
-rw-r--r--lib/url.c7
3 files changed, 16 insertions, 9 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 53f8df14e..701b497e6 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1720,12 +1720,14 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn)
{
struct FTP *ftp= conn->proto.ftp;
- if(ftp->user)
- free(ftp->user);
- if(ftp->passwd)
- free(ftp->passwd);
- if(ftp->entrypath)
- free(ftp->entrypath);
-
+ /* The FTP session may or may not have been allocated/setup at this point! */
+ if(ftp) {
+ if(ftp->user)
+ free(ftp->user);
+ if(ftp->passwd)
+ free(ftp->passwd);
+ if(ftp->entrypath)
+ free(ftp->entrypath);
+ }
return CURLE_OK;
}
diff --git a/lib/transfer.c b/lib/transfer.c
index 1f2c6886f..48706c544 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -955,7 +955,7 @@ CURLcode Curl_perform(CURL *curl)
} while(1); /* loop if Location: */
- if(conn->newurl) {
+ if((CURLE_OK == res) && conn->newurl) {
free(conn->newurl);
conn->newurl = NULL;
}
diff --git a/lib/url.c b/lib/url.c
index 2840d32e5..5bb34be71 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -816,6 +816,9 @@ CURLcode Curl_disconnect(struct connectdata *conn)
free(conn->hostent_buf);
#endif
+ if(conn->newurl)
+ free(conn->newurl);
+
if(conn->path) /* the URL path part */
free(conn->path);
@@ -2147,8 +2150,10 @@ CURLcode Curl_connect(struct UrlData *data,
/* We're not allowed to return failure with memory left allocated
in the connectdata struct, free those here */
conn = (struct connectdata *)*in_connect;
- if(conn)
+ if(conn) {
Curl_disconnect(conn); /* close the connection */
+ *in_connect = NULL; /* return a NULL */
+ }
}
return code;
}