summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2016-06-01 17:37:16 +0000
committertruckman <truckman@FreeBSD.org>2016-06-01 17:37:16 +0000
commitc8f45181287c0cd144f51bd035b3dd26f633a2b2 (patch)
tree4c401d1483b763c5ab749c7d79208f56e9b82fc4 /lib
parent281ac18e42f4f5ca01787dd3b30e1af7c09b8f80 (diff)
downloadFreeBSD-src-c8f45181287c0cd144f51bd035b3dd26f633a2b2.zip
FreeBSD-src-c8f45181287c0cd144f51bd035b3dd26f633a2b2.tar.gz
MFC r300660
Fix 1016718 Resource leak. Don't leak a file descriptor if fchdir() fails. Reported by: Coverity CID: 1016718
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/fts-compat.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c
index 1be41da..90f8995 100644
--- a/lib/libc/gen/fts-compat.c
+++ b/lib/libc/gen/fts-compat.c
@@ -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);
}
OpenPOWER on IntegriCloud