svn commit: r300660 - head/lib/libc/gen
Don Lewis
truckman at FreeBSD.org
Wed May 25 06:55:54 UTC 2016
Author: truckman
Date: Wed May 25 06:55:53 2016
New Revision: 300660
URL: https://svnweb.freebsd.org/changeset/base/300660
Log:
Fix 1016718 Resource leak.
Don't leak a file descriptor if fchdir() fails.
Reported by: Coverity
CID: 1016718
MFC after: 1 week
Modified:
head/lib/libc/gen/fts-compat.c
Modified: head/lib/libc/gen/fts-compat.c
==============================================================================
--- head/lib/libc/gen/fts-compat.c Wed May 25 06:47:28 2016 (r300659)
+++ head/lib/libc/gen/fts-compat.c Wed May 25 06:55:53 2016 (r300660)
@@ -573,8 +573,10 @@ __fts_children_44bsd(FTS *sp, int 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);
}
More information about the svn-src-all
mailing list