]> granicus.if.org Git - curl/commitdiff
Rearranged some allocs so they will be freed correctly in the error path.
authorDan Fandrich <dan@coneharvesters.com>
Sun, 29 Apr 2007 07:04:29 +0000 (07:04 +0000)
committerDan Fandrich <dan@coneharvesters.com>
Sun, 29 Apr 2007 07:04:29 +0000 (07:04 +0000)
lib/url.c

index 6611486a0301e49aac69fa7d3d8d84a75231505d..5ebc9e8b9c02890b41530bda08295bff5a0be87a 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -2860,14 +2860,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
      any failure */
   *in_connect = conn;
 
-  if (data->multi && Curl_multi_canPipeline(data->multi) &&
-      !conn->master_buffer) {
-    /* Allocate master_buffer to be used for pipelining */
-    conn->master_buffer = calloc(BUFSIZE, sizeof (char));
-    if (!conn->master_buffer)
-      return CURLE_OUT_OF_MEMORY;
-  }
-
   /* and we setup a few fields in case we end up actually using this struct */
 
   conn->data = data; /* Setup the association between this connection
@@ -2894,12 +2886,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
   conn->read_pos = 0;
   conn->buf_len = 0;
 
-  /* Initialize the pipeline lists */
-  conn->send_pipe = Curl_llist_alloc((curl_llist_dtor) llist_dtor);
-  conn->recv_pipe = Curl_llist_alloc((curl_llist_dtor) llist_dtor);
-  if (!conn->send_pipe || !conn->recv_pipe)
-    return CURLE_OUT_OF_MEMORY;
-
   /* Store creation time to help future close decision making */
   conn->created = Curl_tvnow();
 
@@ -2910,6 +2896,20 @@ static CURLcode CreateConnection(struct SessionHandle *data,
   conn->bits.ftp_use_epsv = data->set.ftp_use_epsv;
   conn->bits.ftp_use_eprt = data->set.ftp_use_eprt;
 
+  if (data->multi && Curl_multi_canPipeline(data->multi) &&
+      !conn->master_buffer) {
+    /* Allocate master_buffer to be used for pipelining */
+    conn->master_buffer = calloc(BUFSIZE, sizeof (char));
+    if (!conn->master_buffer)
+      return CURLE_OUT_OF_MEMORY;
+  }
+
+  /* Initialize the pipeline lists */
+  conn->send_pipe = Curl_llist_alloc((curl_llist_dtor) llist_dtor);
+  conn->recv_pipe = Curl_llist_alloc((curl_llist_dtor) llist_dtor);
+  if (!conn->send_pipe || !conn->recv_pipe)
+    return CURLE_OUT_OF_MEMORY;
+
   /* This initing continues below, see the comment "Continue connectdata
    * initialization here" */