summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-24 12:27:32 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-24 12:27:32 (GMT)
commitb70681023210eeff3428740808932e3521d691a9 (patch)
tree2fa20cabebca82dad92703d066357632bc38a67e /string.c
parent6f8d3709dac0cd20c01d46cf6e890e07eaf081a2 (diff)
string.c: fstring must not be a shared string
* string.c (fstr_update_callback): fstring must not be a shared string, or the content without RSTRING_FSTR may be freed. [ruby-dev:49188] [Bug #11386] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/string.c b/string.c
index 4e02916..48a9f49 100644
--- a/string.c
+++ b/string.c
@@ -266,8 +266,7 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existi
assert(OBJ_FROZEN(str));
}
if (!BARE_STRING_P(str)) {
- str = str_new_shared(rb_cString, str);
- OBJ_FREEZE_RAW(str);
+ str = str_new_frozen(rb_cString, str);
}
}
RBASIC(str)->flags |= RSTRING_FSTR;
@@ -1002,9 +1001,13 @@ rb_str_new_shared(VALUE str)
VALUE
rb_str_new_frozen(VALUE orig)
{
+ VALUE str;
+
if (OBJ_FROZEN(orig)) return orig;
- return str_new_frozen(rb_obj_class(orig), orig);
+ str = str_new_frozen(rb_obj_class(orig), orig);
+ OBJ_INFECT(str, orig);
+ return str;
}
static VALUE
@@ -1048,7 +1051,6 @@ str_new_frozen(VALUE klass, VALUE orig)
}
rb_enc_cr_str_exact_copy(str, orig);
- OBJ_INFECT(str, orig);
OBJ_FREEZE(str);
return str;
}