diff options
author | Pedro Martelletto <pedro@cvs.openbsd.org> | 2008-12-27 12:30:14 +0000 |
---|---|---|
committer | Pedro Martelletto <pedro@cvs.openbsd.org> | 2008-12-27 12:30:14 +0000 |
commit | 547611311572720bb4b7d2f33eab5388d0d07944 (patch) | |
tree | 4d1c12de33d09887a08e46eb062bc899e90d8741 /lib/libc/gen | |
parent | e35ff78e111f5d4954ceb6cfd856bc4ab2a0d686 (diff) |
Fix file descriptor leak in fts_children(); okay dhill@, millert@,
tedu@, thib@.
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/fts.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 1e069783ac4..ae4bc3f5d1e 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.40 2007/11/06 10:14:53 chl Exp $ */ +/* $OpenBSD: fts.c,v 1.41 2008/12/27 12:30:13 pedro Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -515,8 +515,10 @@ fts_children(FTS *sp, int instr) if ((fd = open(".", O_RDONLY, 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); } |