mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-11 03:40:06 +00:00
Close descriptor in case of error.
This commit is contained in:
parent
1812d50bc9
commit
df811ccf02
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user