Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 May 2017 07:40:42 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319054 - head/lib/libc/tests/nss
Message-ID:  <201705280740.v4S7egsx067817@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sun May 28 07:40:42 2017
New Revision: 319054
URL: https://svnweb.freebsd.org/changeset/base/319054

Log:
  hostent_test_getaddrinfo_eq(..): call freeaddrinfo on `ai` when done
  
  This plugs a leak of memory allocated via getaddrinfo.
  
  MFC after:	1 week
  Reported by:	Coverity
  CID:		1346866
  Sponsored by:	Dell EMC Isilon

Modified:
  head/lib/libc/tests/nss/gethostby_test.c

Modified: head/lib/libc/tests/nss/gethostby_test.c
==============================================================================
--- head/lib/libc/tests/nss/gethostby_test.c	Sun May 28 07:40:09 2017	(r319053)
+++ head/lib/libc/tests/nss/gethostby_test.c	Sun May 28 07:40:42 2017	(r319054)
@@ -776,24 +776,26 @@ hostent_test_getaddrinfo_eq(struct hoste
 		rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
 		if (rv == 0) {
 			printf("not ok - shouldn't have been resolved\n");
-			return (-1);
-		}
+			rv = -1;
+		} else
+			rv = 0;
 	} else {
 		rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
 		if (rv != 0) {
 			printf("not ok - should have been resolved\n");
-			return (-1);
+			rv = -1;
+			goto done;
 		}
-
 		rv = is_hostent_equal(he, ai);
 		if (rv != 0) {
 			printf("not ok - addrinfo and hostent are not equal\n");
-			return (-1);
+			rv = -1;
 		}
-
 	}
-
-	return (0);
+done:
+	if (ai != NULL)
+		freeaddrinfo(ai);
+	return (rv);
 }
 
 static int



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