symbol.c: not freeze the receiver
* symbol.c (rb_str_intern): should not freeze the receiver itself unexpectedly. [ruby-core:71611] [Bug #11721] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8594cab140
commit
c815f7e7cf
@ -1,3 +1,8 @@
|
|||||||
|
Sat Nov 21 04:34:16 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@gmail.com>
|
Fri Nov 20 23:15:18 2015 Naotoshi Seo <sonots@gmail.com>
|
||||||
|
|
||||||
* lib/logger.rb: expose logger mutex
|
* lib/logger.rb: expose logger mutex
|
||||||
|
5
symbol.c
5
symbol.c
@ -674,13 +674,14 @@ rb_str_intern(VALUE str)
|
|||||||
#if USE_SYMBOL_GC
|
#if USE_SYMBOL_GC
|
||||||
enc = rb_enc_get(str);
|
enc = rb_enc_get(str);
|
||||||
ascii = rb_usascii_encoding();
|
ascii = rb_usascii_encoding();
|
||||||
if (enc != ascii) {
|
if (enc != ascii && sym_check_asciionly(str)) {
|
||||||
if (sym_check_asciionly(str)) {
|
|
||||||
str = rb_str_dup(str);
|
str = rb_str_dup(str);
|
||||||
rb_enc_associate(str, ascii);
|
rb_enc_associate(str, ascii);
|
||||||
OBJ_FREEZE(str);
|
OBJ_FREEZE(str);
|
||||||
enc = ascii;
|
enc = ascii;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
str = rb_str_new_frozen(str);
|
||||||
}
|
}
|
||||||
str = rb_fstring(str);
|
str = rb_fstring(str);
|
||||||
type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
|
type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
|
||||||
|
@ -336,4 +336,12 @@ class TestSymbol < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
end;
|
end;
|
||||||
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user