From df811ccf028ee73a9affe643b5f0c3ac55ef2ae8 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 28 Sep 2005 22:38:36 +0000 Subject: Close descriptor in case of error. --- sysdeps/unix/fdopendir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sysdeps/unix/fdopendir.c b/sysdeps/unix/fdopendir.c index fa55a24..3c481fc 100644 --- a/sysdeps/unix/fdopendir.c +++ b/sysdeps/unix/fdopendir.c @@ -20,6 +20,8 @@ #include #include +#include + 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; } -- cgit v1.1