Fix a file descriptor leak in fts_child().

Obtained from:	NetBSD
This commit is contained in:
das 2009-03-04 03:30:21 +00:00
parent 24af7b630b
commit 9dd8da86ee

View File

@ -570,8 +570,10 @@ fts_children(sp, 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);
}