diff options
author | Don Lewis <truckman@FreeBSD.org> | 2016-05-25 07:39:48 +0000 |
---|---|---|
committer | Don Lewis <truckman@FreeBSD.org> | 2016-05-25 07:39:48 +0000 |
commit | 429bf952ae9b1bcddf4b24473aa3413123203123 (patch) | |
tree | 315d4438e115a792282d0d30d8bc48cc65e25ee3 /lib/libfetch | |
parent | d7807d5167814d2adbbe221b6040391d966be958 (diff) | |
download | src-test-429bf952ae9b1bcddf4b24473aa3413123203123.tar.gz src-test-429bf952ae9b1bcddf4b24473aa3413123203123.zip |
Don't leak addrinfo in fetch_bind()
Reported by: Coverity
CID: 1225038
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=300665
Diffstat (limited to 'lib/libfetch')
-rw-r--r-- | lib/libfetch/common.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index 00f8b92399ca8..1536ece56bb1a 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -256,8 +256,11 @@ fetch_bind(int sd, int af, const char *addr) if ((err = getaddrinfo(addr, NULL, &hints, &res0)) != 0) return (-1); for (res = res0; res; res = res->ai_next) - if (bind(sd, res->ai_addr, res->ai_addrlen) == 0) + if (bind(sd, res->ai_addr, res->ai_addrlen) == 0) { + freeaddrinfo(res0); return (0); + } + freeaddrinfo(res0); return (-1); } |