summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-03 04:43:52 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-03 04:43:52 (GMT)
commit3e2942423e38ab70738dd9aafdbbb06e834d3cc4 (patch)
tree637d6b30d6a7a143a03457fbe7ce92c12d864b6c /dir.c
parent73cce16240e1d63a1eb9e1da9d6b3f92335b05ef (diff)
dir.c: GC guard
* dir.c (do_opendir): prevent intermediate string for transcoding from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 5c582dd..c7ba1b0 100644
--- a/dir.c
+++ b/dir.c
@@ -1134,7 +1134,7 @@ do_opendir(const char *path, int flags, rb_encoding *enc)
{
DIR *dirp;
#ifdef _WIN32
- volatile VALUE tmp;
+ VALUE tmp = 0;
if (enc != rb_usascii_encoding() &&
enc != rb_ascii8bit_encoding() &&
enc != rb_utf8_encoding()) {
@@ -1146,6 +1146,9 @@ do_opendir(const char *path, int flags, rb_encoding *enc)
dirp = opendir(path);
if (dirp == NULL && !to_be_ignored(errno))
sys_warning(path);
+#ifdef _WIN32
+ if (tmp) rb_str_resize(tmp, 0); /* GC guard */
+#endif
return dirp;
}