Author: bapt
Date: Wed Feb 11 08:07:32 2015
New Revision: 278563
URL: https://svnweb.freebsd.org/changeset/base/278563

Log:
  MFC: r278172
  
    Plug resources leak
  
    CID:          1125813
    CID:          1125807
    CID:          1125808

Modified:
  stable/10/usr.sbin/pkg/pkg.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/pkg/pkg.c
==============================================================================
--- stable/10/usr.sbin/pkg/pkg.c        Wed Feb 11 07:53:02 2015        
(r278562)
+++ stable/10/usr.sbin/pkg/pkg.c        Wed Feb 11 08:07:32 2015        
(r278563)
@@ -375,8 +375,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 ||
@@ -806,8 +809,11 @@ cleanup:
                close(fd_sig);
                unlink(tmpsig);
        }
-       close(fd_pkg);
-       unlink(tmppkg);
+
+       if (fd_pkg != -1) {
+               close(fd_pkg);
+               unlink(tmppkg);
+       }
 
        return (ret);
 }
@@ -851,7 +857,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) {
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to