]> granicus.if.org Git - curl/commitdiff
easy: fix connection ownership in curl_easy_pause
authorBasuke Suzuki <Basuke.Suzuki@sony.com>
Fri, 5 Jan 2018 23:39:07 +0000 (15:39 -0800)
committerJay Satiro <raysatiro@yahoo.com>
Tue, 9 Jan 2018 07:50:18 +0000 (02:50 -0500)
Before calling Curl_client_chop_write(), change the owner of connection
to the current Curl_easy handle. This will fix the issue #2217.

Fixes https://github.com/curl/curl/issues/2217
Closes https://github.com/curl/curl/pull/2221

lib/easy.c

index 75f332b07a00c68311cafd79c712f51ba3a4f968..d348879132f524c2b1815bdb18ad2f8294711d8a 100644 (file)
@@ -1045,6 +1045,8 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
     unsigned int i;
     unsigned int count = data->state.tempcount;
     struct tempbuf writebuf[3]; /* there can only be three */
+    struct connectdata *conn = data->easy_conn;
+    struct Curl_easy *saved_data = NULL;
 
     /* copy the structs to allow for immediate re-pausing */
     for(i = 0; i < data->state.tempcount; i++) {
@@ -1053,16 +1055,27 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
     }
     data->state.tempcount = 0;
 
+    /* set the connection's current owner */
+    if(conn->data != data) {
+      saved_data = conn->data;
+      conn->data = data;
+    }
+
     for(i = 0; i < count; i++) {
       /* even if one function returns error, this loops through and frees all
          buffers */
       if(!result)
-        result = Curl_client_chop_write(data->easy_conn,
+        result = Curl_client_chop_write(conn,
                                         writebuf[i].type,
                                         writebuf[i].buf,
                                         writebuf[i].len);
       free(writebuf[i].buf);
     }
+
+    /* recover previous owner of the connection */
+    if(saved_data)
+      conn->data = saved_data;
+
     if(result)
       return result;
   }