ruby-changes:37088
From: nobu <ko1@a...>
Date: Wed, 7 Jan 2015 19:19:02 +0900 (JST)
Subject: [ruby-changes:37088] nobu:r49169 (trunk): dir.c: GC guard
nobu 2015-01-07 19:18:45 +0900 (Wed, 07 Jan 2015) New Revision: 49169 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49169 Log: dir.c: GC guard * dir.c (dir_initialize): add GC guard for retrying. the argument of RSTRING_PTR() may be eliminated by optimization. Modified files: trunk/dir.c Index: dir.c =================================================================== --- dir.c (revision 49168) +++ dir.c (revision 49169) @@ -445,6 +445,7 @@ dir_initialize(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/dir.c#L445 rb_encoding *fsenc; VALUE dirname, opt, orig; static ID keyword_ids[1]; + const char *path; if (!keyword_ids[0]) { keyword_ids[0] = rb_intern("encoding"); @@ -472,13 +473,15 @@ dir_initialize(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/dir.c#L473 dp->dir = NULL; dp->path = Qnil; dp->enc = fsenc; - dp->dir = opendir(RSTRING_PTR(dirname)); + path = RSTRING_PTR(dirname); + dp->dir = opendir(path); if (dp->dir == NULL) { if (errno == EMFILE || errno == ENFILE) { rb_gc(); - dp->dir = opendir(RSTRING_PTR(dirname)); + dp->dir = opendir(path); } if (dp->dir == NULL) { + RB_GC_GUARD(dirname); rb_sys_fail_path(orig); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/