Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2016 07:39:49 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300665 - head/lib/libfetch
Message-ID:  <201605250739.u4P7dngg027772@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Wed May 25 07:39:48 2016
New Revision: 300665
URL: https://svnweb.freebsd.org/changeset/base/300665

Log:
  Don't leak addrinfo in fetch_bind()
  
  Reported by:	Coverity
  CID:		1225038
  MFC after:	1 week

Modified:
  head/lib/libfetch/common.c

Modified: head/lib/libfetch/common.c
==============================================================================
--- head/lib/libfetch/common.c	Wed May 25 07:26:22 2016	(r300664)
+++ head/lib/libfetch/common.c	Wed May 25 07:39:48 2016	(r300665)
@@ -256,8 +256,11 @@ fetch_bind(int sd, int af, const char *a
 	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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605250739.u4P7dngg027772>