Close descriptor in case of error.

This commit is contained in:
Ulrich Drepper 2005-09-28 22:38:36 +00:00
parent 1812d50bc9
commit df811ccf02

View File

@ -20,6 +20,8 @@
#include <errno.h>
#include <sys/stat.h>
#include <not-cancel.h>
DIR *
fdopendir (int fd)
@ -27,10 +29,12 @@ fdopendir (int fd)
struct stat64 statbuf;
if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
return NULL;
goto out;
if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0))
{
__set_errno (ENOTDIR);
out:
close_not_cancel_no_status (fd);
return NULL;
}