diff options
author | truckman <truckman@FreeBSD.org> | 2016-06-01 17:43:04 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2016-06-01 17:43:04 +0000 |
commit | 49dc8a6f534cb20087ad9af6fa54756030720c9e (patch) | |
tree | 889e64fc276750e7b2a068db2449317811833cba /lib/libfetch | |
parent | aa1356cf2436c7695cc65a5a27bc635c22c21761 (diff) | |
download | FreeBSD-src-49dc8a6f534cb20087ad9af6fa54756030720c9e.zip FreeBSD-src-49dc8a6f534cb20087ad9af6fa54756030720c9e.tar.gz |
MFC r300665
Don't leak addrinfo in fetch_bind()
Submitted by: Coverity
CID: 1225038
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 76dc4f9..6ae9926 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); } |