mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-26 07:55:01 +00:00
fetch(3): plug some leaks
In the successful case, sockshost is not freed prior to return. The failure case can now be hit after fetch_reopen(), which was not true before. Thus, we need to make sure to clean up all of the conn resources which will also close sd. For all of the points prior to fetch_reopen(), we continue to just close sd. CID: 1419598, 1419616
This commit is contained in:
parent
43cd55db57
commit
5ac6a2c94d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358227
@ -677,6 +677,7 @@ fetch_connect(const char *host, int port, int af, int verbose)
|
||||
if (sockshost)
|
||||
if (!fetch_socks5_init(conn, host, port, verbose))
|
||||
goto fail;
|
||||
free(sockshost);
|
||||
if (cais != NULL)
|
||||
freeaddrinfo(cais);
|
||||
if (sais != NULL)
|
||||
@ -686,7 +687,10 @@ fetch_connect(const char *host, int port, int af, int verbose)
|
||||
fetch_syserr();
|
||||
fail:
|
||||
free(sockshost);
|
||||
if (sd >= 0)
|
||||
/* Fully close if it was opened; otherwise just don't leak the fd. */
|
||||
if (conn != NULL)
|
||||
fetch_close(conn);
|
||||
else if (sd >= 0)
|
||||
close(sd);
|
||||
if (cais != NULL)
|
||||
freeaddrinfo(cais);
|
||||
|
Loading…
Reference in New Issue
Block a user