Author: truckman Date: Wed Jun 1 17:39:03 2016 New Revision: 301151 URL: https://svnweb.freebsd.org/changeset/base/301151
Log: MFC r300662 Fix Coverity CID 1016714 Resource leak in process_file_actions_entry() Don't leak a file descriptor of _dup2() fails (shouldn't happen). Reported by: Coverity CID: 1016714 Modified: stable/10/lib/libc/gen/posix_spawn.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/posix_spawn.c ============================================================================== --- stable/10/lib/libc/gen/posix_spawn.c Wed Jun 1 17:37:16 2016 (r301150) +++ stable/10/lib/libc/gen/posix_spawn.c Wed Jun 1 17:39:03 2016 (r301151) @@ -140,7 +140,7 @@ process_spawnattr(const posix_spawnattr_ static int process_file_actions_entry(posix_spawn_file_actions_entry_t *fae) { - int fd; + int fd, saved_errno; switch (fae->fae_action) { case FAE_OPEN: @@ -149,8 +149,11 @@ process_file_actions_entry(posix_spawn_f if (fd < 0) return (errno); if (fd != fae->fae_fildes) { - if (_dup2(fd, fae->fae_fildes) == -1) - return (errno); + if (_dup2(fd, fae->fae_fildes) == -1) { + saved_errno = errno; + (void)_close(fd); + return (saved_errno); + } if (_close(fd) != 0) { if (errno == EBADF) return (EBADF); _______________________________________________ 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"