summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2016-05-25 06:55:53 +0000
committertruckman <truckman@FreeBSD.org>2016-05-25 06:55:53 +0000
commit82a3029754321218d2c91bf6c32481eb43251a5c (patch)
tree7bc387ee496ac249a3163e14ffe84a798c4c3847 /lib/libc
parent49a189c5462bd7a51998e304b490aff53b3968fa (diff)
downloadFreeBSD-src-82a3029754321218d2c91bf6c32481eb43251a5c.zip
FreeBSD-src-82a3029754321218d2c91bf6c32481eb43251a5c.tar.gz
Fix 1016718 Resource leak.
Don't leak a file descriptor if fchdir() fails. Reported by: Coverity CID: 1016718 MFC after: 1 week
Diffstat (limited to 'lib/libc')
-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 cf1daef..c34a281 100644
--- a/lib/libc/gen/fts-compat.c
+++ b/lib/libc/gen/fts-compat.c
@@ -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);
}
OpenPOWER on IntegriCloud