summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2016-05-25 07:39:48 +0000
committertruckman <truckman@FreeBSD.org>2016-05-25 07:39:48 +0000
commitbf54148fc3b7c68aac184e4e5f90eb28b0f04dc5 (patch)
tree315d4438e115a792282d0d30d8bc48cc65e25ee3
parent5e2ae27f2775724eda157b0198d9a46337833225 (diff)
downloadFreeBSD-src-bf54148fc3b7c68aac184e4e5f90eb28b0f04dc5.zip
FreeBSD-src-bf54148fc3b7c68aac184e4e5f90eb28b0f04dc5.tar.gz
Don't leak addrinfo in fetch_bind()
Reported by: Coverity CID: 1225038 MFC after: 1 week
-rw-r--r--lib/libfetch/common.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index 00f8b92..1536ece 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);
}
OpenPOWER on IntegriCloud