Fix 1016718 Resource leak.

Don't leak a file descriptor if fchdir() fails.

Reported by:	Coverity
CID:		1016718
MFC after:	1 week
This commit is contained in:
truckman 2016-05-25 06:55:53 +00:00
parent 49a189c546
commit 82a3029754

View File

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