hostip: (macOS) free returned memory of SCDynamicStoreCopyProxies

From Apples documentation on SCDynamicStoreCopyProxies, "Return Value: A
dictionary of key-value pairs that represent the current internet proxy
settings, or NULL if no proxy settings have been defined or if an error
occurred. You must release the returned value."

Failure to release the returned value of SCDynamicStoreCopyProxies can
result in a memory leak.

Source: https://developer.apple.com/documentation/systemconfiguration/1517088-scdynamicstorecopyproxies

Closes #7265
This commit is contained in:
Gregory Muchka 2021-06-15 18:12:49 -06:00 committed by Daniel Stenberg
parent 47386775ed
commit 62be096085
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 30 additions and 26 deletions

View file

@ -579,7 +579,6 @@ enum resolve_t Curl_resolv(struct Curl_easy *data,
CURLcode result;
enum resolve_t rc = CURLRESOLV_ERROR; /* default to failure */
struct connectdata *conn = data->conn;
*entry = NULL;
conn->bits.doh = FALSE; /* default is not */
@ -626,16 +625,20 @@ enum resolve_t Curl_resolv(struct Curl_easy *data,
}
#if defined(ENABLE_IPV6) && defined(CURL_OSX_CALL_COPYPROXIES)
/*
* The automagic conversion from IPv4 literals to IPv6 literals only works
* if the SCDynamicStoreCopyProxies system function gets called first. As
* Curl currently doesn't support system-wide HTTP proxies, we therefore
* don't use any value this function might return.
*
* This function is only available on a macOS and is not needed for
* IPv4-only builds, hence the conditions above.
*/
SCDynamicStoreCopyProxies(NULL);
{
/*
* The automagic conversion from IPv4 literals to IPv6 literals only
* works if the SCDynamicStoreCopyProxies system function gets called
* first. As Curl currently doesn't support system-wide HTTP proxies, we
* therefore don't use any value this function might return.
*
* This function is only available on a macOS and is not needed for
* IPv4-only builds, hence the conditions above.
*/
CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL);
if(dict)
CFRelease(dict);
}
#endif
#ifndef USE_RESOLVE_ON_IPS