ruby-changes:25122
From: nobu <ko1@a...>
Date: Sat, 13 Oct 2012 03:02:13 +0900 (JST)
Subject: [ruby-changes:25122] nobu:r37174 (trunk): file.c: GC guard
nobu 2012-10-13 03:01:56 +0900 (Sat, 13 Oct 2012) New Revision: 37174 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37174 Log: file.c: GC guard * file.c (realpath_rec): prevent link from GC while link_names refers the content. Modified files: trunk/ChangeLog trunk/file.c Index: ChangeLog =================================================================== --- ChangeLog (revision 37173) +++ ChangeLog (revision 37174) @@ -1,3 +1,8 @@ +Sat Oct 13 03:01:53 2012 Nobuyoshi Nakada <nobu@r...> + + * file.c (realpath_rec): prevent link from GC while link_names refers + the content. + Sat Oct 13 01:37:48 2012 NAKAMURA Usaku <usa@r...> * test/ruby/test_regexp.rb Index: file.c =================================================================== --- file.c (revision 37173) +++ file.c (revision 37174) @@ -3389,6 +3389,7 @@ #ifdef HAVE_READLINK if (S_ISLNK(sbuf.st_mode)) { VALUE link; + volatile VALUE link_orig = Qnil; const char *link_prefix, *link_names; long link_prefixlen; rb_hash_aset(loopcheck, testpath, ID2SYM(resolving)); @@ -3398,6 +3399,7 @@ link_prefixlen = link_names - link_prefix; if (link_prefixlen > 0) { rb_encoding *enc, *linkenc = rb_enc_get(link); + link_orig = link; link = rb_str_subseq(link, 0, link_prefixlen); enc = rb_enc_check(*resolvedp, link); if (enc != linkenc) link = rb_str_conv_enc(link, linkenc, enc); @@ -3405,6 +3407,7 @@ *prefixlenp = link_prefixlen; } realpath_rec(prefixlenp, resolvedp, link_names, loopcheck, strict, *unresolved_firstsep == '\0'); + RB_GC_GUARD(link_orig); rb_hash_aset(loopcheck, testpath, rb_str_dup_frozen(*resolvedp)); } else -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/