ruby-changes:39282
From: nobu <ko1@a...>
Date: Fri, 24 Jul 2015 21:27:46 +0900 (JST)
Subject: [ruby-changes:39282] nobu:r51363 (trunk): string.c: fstring must not be a shared string
nobu 2015-07-24 21:27:32 +0900 (Fri, 24 Jul 2015) New Revision: 51363 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51363 Log: 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] Modified files: trunk/ChangeLog trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51362) +++ ChangeLog (revision 51363) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jul 24 21:27:29 2015 Nobuyoshi Nakada <nobu@r...> + + * 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] + Fri Jul 24 20:09:43 2015 Naohisa Goto <ngotogenome@g...> * test/rinda/test_rinda.rb (RingIPv6#prepare_ipv6): prevent to use Index: string.c =================================================================== --- string.c (revision 51362) +++ string.c (revision 51363) @@ -266,8 +266,7 @@ fstr_update_callback(st_data_t *key, st_ https://github.com/ruby/ruby/blob/trunk/string.c#L266 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) https://github.com/ruby/ruby/blob/trunk/string.c#L1001 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) https://github.com/ruby/ruby/blob/trunk/string.c#L1051 } rb_enc_cr_str_exact_copy(str, orig); - OBJ_INFECT(str, orig); OBJ_FREEZE(str); return str; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/