summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-28 00:22:45 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-28 00:22:45 +0000
commitd7df3e28306267d9e66d8493aa61642c32a145a3 (patch)
tree90520173aa305a44214e7fa20ea4e109a584569b /string.c
parent8c91dfb91b49254ed7c0c5409775af9478c4f9ad (diff)
* string.c (rb_fstring): fstrings should be ELTS_SHARED.
If we resurrect dying objects (non-marked, but not swept yet), pointing shared string can be collected. To avoid such issue, fstrings (recorded to fstring_table) should not be ELTS_SHARED (should not have a shared string). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/string.c b/string.c
index c6c1497ea4..231bb2f4fd 100644
--- a/string.c
+++ b/string.c
@@ -148,7 +148,14 @@ rb_fstring(VALUE str)
rb_gc_resurrect(str);
}
else {
- str = rb_str_new_frozen(str);
+ if (STR_SHARED_P(str)) {
+ /* str should not be shared */
+ str = rb_enc_str_new(RSTRING_PTR(str), RSTRING_LEN(str), STR_ENC_GET(str));
+ OBJ_FREEZE(str);
+ }
+ else {
+ str = rb_str_new_frozen(str);
+ }
RBASIC(str)->flags |= RSTRING_FSTR;
st_insert(frozen_strings, str, str);
}