Reported in #1561470 (http://curl.haxx.se/bug/view.cgi?id=1561470), libcurl
would crash if a bad function sequence was used when shutting down after using the multi interface (i.e using easy_cleanup after multi_cleanup) so precautions have been added to make sure it doesn't any more - test case 529 was added to verify.
This commit is contained in:
30
lib/url.c
30
lib/url.c
@@ -269,13 +269,23 @@ CURLcode Curl_close(struct SessionHandle *data)
|
||||
the multi handle, since that function uses the magic
|
||||
field! */
|
||||
|
||||
if(data->state.connc && (data->state.connc->type == CONNCACHE_PRIVATE)) {
|
||||
/* close all connections still alive that are in the private connection
|
||||
cache, as we no longer have the pointer left to the shared one. */
|
||||
close_connections(data);
|
||||
if(data->state.connc) {
|
||||
|
||||
/* free the connection cache if allocated privately */
|
||||
Curl_rm_connc(data->state.connc);
|
||||
if(data->state.connc->type == CONNCACHE_PRIVATE) {
|
||||
/* close all connections still alive that are in the private connection
|
||||
cache, as we no longer have the pointer left to the shared one. */
|
||||
close_connections(data);
|
||||
|
||||
/* free the connection cache if allocated privately */
|
||||
Curl_rm_connc(data->state.connc);
|
||||
}
|
||||
}
|
||||
|
||||
if(data->state.shared_conn) {
|
||||
/* marked to be used by a pending connection so we can't kill this handle
|
||||
just yet */
|
||||
data->state.closed = TRUE;
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
if ( ! (data->share && data->share->hostcache) ) {
|
||||
@@ -284,14 +294,6 @@ CURLcode Curl_close(struct SessionHandle *data)
|
||||
}
|
||||
}
|
||||
|
||||
if(data->state.shared_conn) {
|
||||
/* this handle is still being used by a shared connection cache and thus
|
||||
we leave it around for now */
|
||||
Curl_multi_add_closure(data->state.shared_conn, data);
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/* Free the pathbuffer */
|
||||
Curl_safefree(data->reqdata.pathbuffer);
|
||||
Curl_safefree(data->reqdata.proto.generic);
|
||||
|
Reference in New Issue
Block a user