Fix a file descriptor leak in fts_child().

Obtained from:	NetBSD
This commit is contained in:
David Schultz 2009-03-04 03:30:21 +00:00
parent 346e3178ea
commit ce5c3df1b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189348

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);
}