summaryrefslogtreecommitdiff
path: root/symbol.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-20 19:34:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-20 19:34:19 +0000
commitc815f7e7cf7bad7df5e107544cd739f294470433 (patch)
tree4f9355937a5ff85c4e00f670dbf0ee5c4e8df84a /symbol.c
parent8594cab1403199685a35d9e8b7236f5598510119 (diff)
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
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/symbol.c b/symbol.c
index 4fe3adf724..65ffab0958 100644
--- a/symbol.c
+++ b/symbol.c
@@ -674,13 +674,14 @@ rb_str_intern(VALUE str)
#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);