From 3e2942423e38ab70738dd9aafdbbb06e834d3cc4 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 3 Feb 2015 04:43:52 +0000 Subject: 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 --- dir.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dir.c b/dir.c index 5c582ddb76..c7ba1b0c04 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; } -- cgit v1.2.3