Author: truckman
Date: Wed Jun  1 17:37:16 2016
New Revision: 301150
URL: https://svnweb.freebsd.org/changeset/base/301150

Log:
  MFC r300660
  
  Fix 1016718 Resource leak.
  
  Don't leak a file descriptor if fchdir() fails.
  
  Reported by:  Coverity
  CID:          1016718

Modified:
  stable/10/lib/libc/gen/fts-compat.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/fts-compat.c
==============================================================================
--- stable/10/lib/libc/gen/fts-compat.c Wed Jun  1 17:35:03 2016        
(r301149)
+++ stable/10/lib/libc/gen/fts-compat.c Wed Jun  1 17:37:16 2016        
(r301150)
@@ -586,8 +586,10 @@ __fts_children_44bsd(sp, instr)
        if ((fd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0)
                return (NULL);
        sp->fts_child = fts_build(sp, instr);
-       if (fchdir(fd))
+       if (fchdir(fd)) {
+               (void)_close(fd);
                return (NULL);
+       }
        (void)_close(fd);
        return (sp->fts_child);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to