dir.c: fix FD leaks

* dir.c (do_opendir): close FD when fdopendir failed, e.g.,
  ENOTDIR.  [Feature#13056]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-05-27 01:04:23 +00:00
parent 015d05c6e6
commit 1dec75c02f
1 changed files with 2 additions and 2 deletions

4
dir.c
View File

@ -1372,11 +1372,11 @@ do_opendir(const int basefd, const char *path, int flags, rb_encoding *enc,
#endif
if (dirp) break;
e = errno;
/* fallback */
case 0:
#if USE_OPENDIR_AT
if (fd >= 0) close(fd);
#endif
/* fallback */
case 0:
*status = 0;
if (to_be_ignored(e)) break;
if (errfunc) {