summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-27 01:04:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-27 01:04:23 +0000
commit1dec75c02ffbb45f4494f285f5c20a8758cbd938 (patch)
treeeb43c3e576de586e2a1b4db325296a99e2c0690f /dir.c
parent015d05c6e6e63104f5e9653663a6011684303cdf (diff)
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
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index d61b1f9..f4ee1b9 100644
--- a/dir.c
+++ b/dir.c
@@ -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) {