Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Feb 2015 00:10:58 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r278172 - head/usr.sbin/pkg
Message-ID:  <201502040010.t140Awaq064586@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Wed Feb  4 00:10:57 2015
New Revision: 278172
URL: https://svnweb.freebsd.org/changeset/base/278172

Log:
  Plug resources leak
  
  CID:		1125813
  CID:		1125807
  CID:		1125808
  MFC after:	1 week

Modified:
  head/usr.sbin/pkg/pkg.c

Modified: head/usr.sbin/pkg/pkg.c
==============================================================================
--- head/usr.sbin/pkg/pkg.c	Tue Feb  3 22:49:12 2015	(r278171)
+++ head/usr.sbin/pkg/pkg.c	Wed Feb  4 00:10:57 2015	(r278172)
@@ -371,8 +371,11 @@ load_fingerprints(const char *path, int 
 		return (NULL);
 	STAILQ_INIT(fingerprints);
 
-	if ((d = opendir(path)) == NULL)
+	if ((d = opendir(path)) == NULL) {
+		free(fingerprints);
+
 		return (NULL);
+	}
 
 	while ((ent = readdir(d))) {
 		if (strcmp(ent->d_name, ".") == 0 ||
@@ -799,8 +802,11 @@ cleanup:
 		close(fd_sig);
 		unlink(tmpsig);
 	}
-	close(fd_pkg);
-	unlink(tmppkg);
+
+	if (fd_pkg != -1) {
+		close(fd_pkg);
+		unlink(tmppkg);
+	}
 
 	return (ret);
 }
@@ -849,7 +855,7 @@ bootstrap_pkg_local(const char *pkgpath,
 
 	if (config_string(SIGNATURE_TYPE, &signature_type) != 0) {
 		warnx("Error looking up SIGNATURE_TYPE");
-		return (-1);
+		goto cleanup;
 	}
 	if (signature_type != NULL &&
 	    strcasecmp(signature_type, "FINGERPRINTS") == 0) {



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