diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-24 12:27:32 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-24 12:27:32 +0000 |
commit | c33e46e1e0801ea3625bf84e56410f0f273306d7 (patch) | |
tree | 2fa20cabebca82dad92703d066357632bc38a67e /string.c | |
parent | f99babd227174700317d591a836b15ea05a58d2b (diff) | |
download | ruby-c33e46e1e0801ea3625bf84e56410f0f273306d7.tar.gz |
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.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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; } |