aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-11-17 14:03:58 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-11-17 14:03:58 +0000
commit868488b518706a7eba8e380eeb51d71066a73df8 (patch)
tree140d2c124db768173f2ffad5afacea42beba0b75 /lib
parent7f77a061dd9b40637e44cef6332c4855c2336e55 (diff)
memory leak cleanup campaign
Diffstat (limited to 'lib')
-rw-r--r--lib/highlevel.c2
-rw-r--r--lib/http.c3
-rw-r--r--lib/url.c65
3 files changed, 48 insertions, 22 deletions
diff --git a/lib/highlevel.c b/lib/highlevel.c
index fbdde4bff..0e6ac8e27 100644
--- a/lib/highlevel.c
+++ b/lib/highlevel.c
@@ -620,7 +620,7 @@ CURLcode curl_transfer(CURL *curl)
{
CURLcode res;
struct UrlData *data = curl;
- struct connectdata *c_connect;
+ struct connectdata *c_connect=NULL;
pgrsStartNow(data);
diff --git a/lib/http.c b/lib/http.c
index 70870f7b2..d5241acec 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -390,6 +390,7 @@ CURLcode http(struct connectdata *conn)
if(co) {
int count=0;
+ struct Cookie *store=co;
/* now loop through all cookies that matched */
while(co) {
if(co->value && strlen(co->value)) {
@@ -405,7 +406,7 @@ CURLcode http(struct connectdata *conn)
if(count) {
add_buffer(req_buffer, "\r\n", 2);
}
- cookie_freelist(co); /* free the cookie list */
+ cookie_freelist(store); /* free the cookie list */
co=NULL;
}
diff --git a/lib/url.c b/lib/url.c
index eea7808ea..057e163a6 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -685,26 +685,7 @@ CURLcode curl_disconnect(CURLconnect *c_connect)
return CURLE_OK;
}
-
-/*
- * NAME curl_connect()
- *
- * DESCRIPTION
- *
- * Connects to the peer server and performs the initial setup. This function
- * writes a connect handle to its second argument that is a unique handle for
- * this connect. This allows multiple connects from the same handle returned
- * by curl_open().
- *
- * EXAMPLE
- *
- * CURLCode result;
- * CURL curl;
- * CURLconnect connect;
- * result = curl_connect(curl, &connect);
- */
-
-CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
+static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
{
char *tmp;
char *buf;
@@ -1537,6 +1518,50 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
return CURLE_OK;
}
+CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
+{
+ CURLcode code;
+ struct connectdata *conn;
+
+ /* call the stuff that needs to be called */
+ code = _connect(curl, in_connect);
+
+ if(CURLE_OK != code) {
+ /* 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->hostent_buf)
+ free(conn->hostent_buf);
+ free(conn);
+ *in_connect=NULL;
+ }
+ }
+ return code;
+}
+
+
+/*
+ * NAME curl_connect()
+ *
+ * DESCRIPTION
+ *
+ * Connects to the peer server and performs the initial setup. This function
+ * writes a connect handle to its second argument that is a unique handle for
+ * this connect. This allows multiple connects from the same handle returned
+ * by curl_open().
+ *
+ * EXAMPLE
+ *
+ * CURLCode result;
+ * CURL curl;
+ * CURLconnect connect;
+ * result = curl_connect(curl, &connect);
+ */
+
+
+
+
CURLcode curl_done(CURLconnect *c_connect)
{
struct connectdata *conn = c_connect;