diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-06 05:14:53 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-06 05:14:53 +0000 |
commit | 326ce405209d3910d014d7ed4e950f3149ee839e (patch) | |
tree | f983c396ec69c57ec1687eb4f59977e2a6ad0f7e /file.c | |
parent | 4be94836bd5eb2e2815c5b04c5427e05e9dc98d8 (diff) |
merge revision(s) 37174: [Backport #7754]
* file.c (realpath_rec): prevent link from GC while link_names refers
the content.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@39092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -3378,6 +3378,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l #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)); @@ -3387,6 +3388,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l 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); @@ -3394,6 +3396,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE l *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 |