mirror of
https://github.com/curl/curl.git
synced 2026-08-25 18:03:36 +03:00
hostip.c: fix leak of addrinfo
When creating a dns entry, the addrinfo is passed into the entry on success and needed deallocation by the caller on failure. Change the signature to have Curl_dnscache_mk_entry() *always* take ownership of the addrinfo, even on failure. Change parameter to address of pointer so that call always clears it. This makes the handling of failures to Curl_dnscache_mk_entry() simpler. Fixes #20465 Closes #20468
This commit is contained in:
parent
a84b041281
commit
ffdbc04c7b
5 changed files with 24 additions and 27 deletions
|
|
@ -151,13 +151,14 @@ void Curl_printable_address(const struct Curl_addrinfo *ip,
|
|||
* The entry is created with a reference count of 1.
|
||||
* Use `Curl_resolv_unlink()` to release your hold on it.
|
||||
*
|
||||
* The call takes ownership of `addr`and makes a copy of `hostname`.
|
||||
* The call takes ownership of `addr`, even in case of failure, and always
|
||||
* clears `*paddr`. It makes a copy of `hostname`.
|
||||
*
|
||||
* Returns entry or NULL on OOM.
|
||||
*/
|
||||
struct Curl_dns_entry *
|
||||
Curl_dnscache_mk_entry(struct Curl_easy *data,
|
||||
struct Curl_addrinfo *addr,
|
||||
struct Curl_addrinfo **paddr,
|
||||
const char *hostname,
|
||||
size_t hostlen, /* length or zero */
|
||||
int port,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue