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);
}
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"