file.c: GC guard
* file.c (realpath_rec): prevent link from GC while link_names refers the content. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5ea65366f5
commit
872a47c1bf
@ -1,3 +1,8 @@
|
|||||||
|
Sat Oct 13 03:01:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (realpath_rec): prevent link from GC while link_names refers
|
||||||
|
the content.
|
||||||
|
|
||||||
Sat Oct 13 01:37:48 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
Sat Oct 13 01:37:48 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* test/ruby/test_regexp.rb
|
* test/ruby/test_regexp.rb
|
||||||
|
3
file.c
3
file.c
@ -3389,6 +3389,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l
|
|||||||
#ifdef HAVE_READLINK
|
#ifdef HAVE_READLINK
|
||||||
if (S_ISLNK(sbuf.st_mode)) {
|
if (S_ISLNK(sbuf.st_mode)) {
|
||||||
VALUE link;
|
VALUE link;
|
||||||
|
volatile VALUE link_orig = Qnil;
|
||||||
const char *link_prefix, *link_names;
|
const char *link_prefix, *link_names;
|
||||||
long link_prefixlen;
|
long link_prefixlen;
|
||||||
rb_hash_aset(loopcheck, testpath, ID2SYM(resolving));
|
rb_hash_aset(loopcheck, testpath, ID2SYM(resolving));
|
||||||
@ -3398,6 +3399,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l
|
|||||||
link_prefixlen = link_names - link_prefix;
|
link_prefixlen = link_names - link_prefix;
|
||||||
if (link_prefixlen > 0) {
|
if (link_prefixlen > 0) {
|
||||||
rb_encoding *enc, *linkenc = rb_enc_get(link);
|
rb_encoding *enc, *linkenc = rb_enc_get(link);
|
||||||
|
link_orig = link;
|
||||||
link = rb_str_subseq(link, 0, link_prefixlen);
|
link = rb_str_subseq(link, 0, link_prefixlen);
|
||||||
enc = rb_enc_check(*resolvedp, link);
|
enc = rb_enc_check(*resolvedp, link);
|
||||||
if (enc != linkenc) link = rb_str_conv_enc(link, linkenc, enc);
|
if (enc != linkenc) link = rb_str_conv_enc(link, linkenc, enc);
|
||||||
@ -3405,6 +3407,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l
|
|||||||
*prefixlenp = link_prefixlen;
|
*prefixlenp = link_prefixlen;
|
||||||
}
|
}
|
||||||
realpath_rec(prefixlenp, resolvedp, link_names, loopcheck, strict, *unresolved_firstsep == '\0');
|
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));
|
rb_hash_aset(loopcheck, testpath, rb_str_dup_frozen(*resolvedp));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user