mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 17:31:46 -05:00
ares: memory leak fix
The double name resolve trick used with c-ares could leave allocated memory in 'temp_ai' if the operation was aborted in the middle.
This commit is contained in:
parent
2d356ba168
commit
ef19e30985
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -83,10 +83,6 @@ void Curl_async_cancel(struct connectdata *conn)
|
|||||||
Curl_freeaddrinfo(conn->async.temp_ai);
|
Curl_freeaddrinfo(conn->async.temp_ai);
|
||||||
conn->async.temp_ai = NULL;
|
conn->async.temp_ai = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for ares-using, make sure all possible outstanding requests are properly
|
|
||||||
cancelled before we proceed */
|
|
||||||
ares_cancel(conn->data->state.areschannel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -126,6 +122,10 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn,
|
|||||||
if(--conn->async.num_pending > 0)
|
if(--conn->async.num_pending > 0)
|
||||||
/* We are not done yet. Just return. */
|
/* We are not done yet. Just return. */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
|
/* make sure the temp pointer is cleared and isn't pointing to something
|
||||||
|
we take care of below */
|
||||||
|
conn->async.temp_ai = NULL;
|
||||||
#endif
|
#endif
|
||||||
if(data->share)
|
if(data->share)
|
||||||
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
|
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
|
||||||
@ -147,8 +147,10 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn,
|
|||||||
if(--conn->async.num_pending > 0) {
|
if(--conn->async.num_pending > 0) {
|
||||||
/* We are not done yet. Clean up and return.
|
/* We are not done yet. Clean up and return.
|
||||||
This function will be called again. */
|
This function will be called again. */
|
||||||
if(conn->async.temp_ai)
|
if(conn->async.temp_ai) {
|
||||||
Curl_freeaddrinfo(conn->async.temp_ai);
|
Curl_freeaddrinfo(conn->async.temp_ai);
|
||||||
|
conn->async.temp_ai = NULL;
|
||||||
|
}
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -178,9 +180,12 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn,
|
|||||||
Curl_freeaddrinfo(conn->async.temp_ai);
|
Curl_freeaddrinfo(conn->async.temp_ai);
|
||||||
rc = CURLE_OUT_OF_MEMORY;
|
rc = CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data->share)
|
if(data->share)
|
||||||
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
|
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
|
||||||
|
|
||||||
|
/* make sure the temp pointer is cleared and isn't pointing to
|
||||||
|
something we've taken care of already */
|
||||||
|
conn->async.temp_ai = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -5241,6 +5241,8 @@ CURLcode Curl_done(struct connectdata **connp,
|
|||||||
data->req.location = NULL;
|
data->req.location = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Curl_async_cancel(conn);
|
||||||
|
|
||||||
if(conn->dns_entry) {
|
if(conn->dns_entry) {
|
||||||
Curl_resolv_unlock(data, conn->dns_entry); /* done with this */
|
Curl_resolv_unlock(data, conn->dns_entry); /* done with this */
|
||||||
conn->dns_entry = NULL;
|
conn->dns_entry = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user