summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-06 05:14:53 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-06 05:14:53 +0000
commit326ce405209d3910d014d7ed4e950f3149ee839e (patch)
treef983c396ec69c57ec1687eb4f59977e2a6ad0f7e
parent4be94836bd5eb2e2815c5b04c5427e05e9dc98d8 (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
-rw-r--r--ChangeLog5
-rw-r--r--file.c3
-rw-r--r--version.h2
3 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4aba8e88e1..20f8c8f4fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Feb 6 14:14:38 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (realpath_rec): prevent link from GC while link_names refers
+ the content.
+
Wed Feb 6 14:13:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* missing/setproctitle.c (environ): use (*_NSGetEnviron()) instead of
diff --git a/file.c b/file.c
index 50fa5c7f2c..fd64116d24 100644
--- a/file.c
+++ b/file.c
@@ -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
diff --git a/version.h b/version.h
index dddec3175f..6fcee80330 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 377
+#define RUBY_PATCHLEVEL 378
#define RUBY_RELEASE_DATE "2013-02-06"
#define RUBY_RELEASE_YEAR 2013