diff options
| author | Basuke Suzuki <Basuke.Suzuki@sony.com> | 2018-01-05 15:39:07 -0800 | 
|---|---|---|
| committer | Jay Satiro <raysatiro@yahoo.com> | 2018-01-09 02:50:18 -0500 | 
| commit | 2a6dbb8155d3e96640d74f56a3be5cd557c33769 (patch) | |
| tree | c237493dc7e1662db393d10c77b742087a92e598 | |
| parent | 89f68047347cef29f8f4cab6a0ae3ff35d467c37 (diff) | |
easy: fix connection ownership in curl_easy_pause
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
| -rw-r--r-- | lib/easy.c | 15 | 
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/easy.c b/lib/easy.c index 75f332b07..d34887913 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -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;    }  | 
