lib/fetch/common.c: fix CID 284966 (Resource leak).
This commit is contained in:
parent
7b623783c8
commit
359721baa6
@ -710,6 +710,8 @@ fetch_connect(struct url *url, int af, int verbose)
|
|||||||
if (strcasecmp(socks_url->scheme, SCHEME_SOCKS5) != 0) {
|
if (strcasecmp(socks_url->scheme, SCHEME_SOCKS5) != 0) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fetch_info("SOCKS_PROXY scheme '%s' not supported", socks_url->scheme);
|
fetch_info("SOCKS_PROXY scheme '%s' not supported", socks_url->scheme);
|
||||||
|
|
||||||
|
fetchFreeURL(socks_url);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!socks_url->port)
|
if (!socks_url->port)
|
||||||
@ -730,6 +732,7 @@ fetch_connect(struct url *url, int af, int verbose)
|
|||||||
hints.ai_protocol = 0;
|
hints.ai_protocol = 0;
|
||||||
if ((error = getaddrinfo(connurl->host, pbuf, &hints, &res0)) != 0) {
|
if ((error = getaddrinfo(connurl->host, pbuf, &hints, &res0)) != 0) {
|
||||||
netdb_seterr(error);
|
netdb_seterr(error);
|
||||||
|
fetchFreeURL(socks_url);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,10 +741,12 @@ fetch_connect(struct url *url, int af, int verbose)
|
|||||||
|
|
||||||
sd = happy_eyeballs_connect(res0, verbose);
|
sd = happy_eyeballs_connect(res0, verbose);
|
||||||
freeaddrinfo(res0);
|
freeaddrinfo(res0);
|
||||||
if (sd == -1)
|
if (sd == -1) {
|
||||||
|
fetchFreeURL(socks_url);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
if ((conn = fetch_reopen(sd)) == NULL) {
|
if ((conn = fetch_reopen(sd)) == NULL) {
|
||||||
|
fetchFreeURL(socks_url);
|
||||||
fetch_syserr();
|
fetch_syserr();
|
||||||
close(sd);
|
close(sd);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -749,6 +754,7 @@ fetch_connect(struct url *url, int af, int verbose)
|
|||||||
if (socks_url) {
|
if (socks_url) {
|
||||||
if (strcasecmp(socks_url->scheme, SCHEME_SOCKS5) == 0) {
|
if (strcasecmp(socks_url->scheme, SCHEME_SOCKS5) == 0) {
|
||||||
if (fetch_socks5(conn, url, socks_url, verbose) != 0) {
|
if (fetch_socks5(conn, url, socks_url, verbose) != 0) {
|
||||||
|
fetchFreeURL(socks_url);
|
||||||
fetch_syserr();
|
fetch_syserr();
|
||||||
close(sd);
|
close(sd);
|
||||||
free(conn);
|
free(conn);
|
||||||
@ -758,6 +764,7 @@ fetch_connect(struct url *url, int af, int verbose)
|
|||||||
}
|
}
|
||||||
conn->cache_url = fetchCopyURL(url);
|
conn->cache_url = fetchCopyURL(url);
|
||||||
conn->cache_af = af;
|
conn->cache_af = af;
|
||||||
|
fetchFreeURL(socks_url);
|
||||||
return (conn);
|
return (conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user