ruby-changes:40607
From: nobu <ko1@a...>
Date: Sat, 21 Nov 2015 04:34:42 +0900 (JST)
Subject: [ruby-changes:40607] nobu:r52686 (trunk): symbol.c: not freeze the receiver
nobu 2015-11-21 04:34:19 +0900 (Sat, 21 Nov 2015) New Revision: 52686 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52686 Log: symbol.c: not freeze the receiver * symbol.c (rb_str_intern): should not freeze the receiver itself unexpectedly. [ruby-core:71611] [Bug #11721] Modified files: trunk/ChangeLog trunk/symbol.c trunk/test/ruby/test_symbol.rb Index: symbol.c =================================================================== --- symbol.c (revision 52685) +++ symbol.c (revision 52686) @@ -674,13 +674,14 @@ rb_str_intern(VALUE str) https://github.com/ruby/ruby/blob/trunk/symbol.c#L674 #if USE_SYMBOL_GC enc = rb_enc_get(str); ascii = rb_usascii_encoding(); - if (enc != ascii) { - if (sym_check_asciionly(str)) { - str = rb_str_dup(str); - rb_enc_associate(str, ascii); - OBJ_FREEZE(str); - enc = ascii; - } + if (enc != ascii && sym_check_asciionly(str)) { + str = rb_str_dup(str); + rb_enc_associate(str, ascii); + OBJ_FREEZE(str); + enc = ascii; + } + else { + str = rb_str_new_frozen(str); } str = rb_fstring(str); type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN); Index: ChangeLog =================================================================== --- ChangeLog (revision 52685) +++ ChangeLog (revision 52686) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Nov 21 04:34:16 2015 Nobuyoshi Nakada <nobu@r...> + + * symbol.c (rb_str_intern): should not freeze the receiver itself + unexpectedly. [ruby-core:71611] [Bug #11721] + Fri Nov 20 23:15:18 2015 Naotoshi Seo <sonots@g...> * lib/logger.rb: expose logger mutex Index: test/ruby/test_symbol.rb =================================================================== --- test/ruby/test_symbol.rb (revision 52685) +++ test/ruby/test_symbol.rb (revision 52686) @@ -336,4 +336,12 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L336 } end; end + + def test_not_freeze + bug11721 = '[ruby-core:71611] [Bug #11721]' + str = "\u{1f363}".taint + assert_not_predicate(str, :frozen?) + assert_equal str, str.to_sym.to_s + assert_not_predicate(str, :frozen?, bug11721) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/