diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/highlevel.c | 2 | ||||
-rw-r--r-- | lib/http.c | 3 | ||||
-rw-r--r-- | lib/url.c | 65 |
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; } @@ -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; |