summaryrefslogtreecommitdiff
path: root/symbol.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-29 12:38:43 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-29 12:38:43 (GMT)
commitede1c141c62015eb413655310f046906775b375b (patch)
tree136d3edd527362e59850bb3f5ba5704741030bfa /symbol.c
parent184cf1f710d42446d75a862f63c01bb2d401e562 (diff)
symbol.c: fix dynamic symbol hash value
* hash.c (any_hash), symbol.c (dsymbol_alloc): fix dynamic symbol hash value by restricting in Fixnum range, that is `long`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/symbol.c b/symbol.c
index 9e2fccd..899ccda 100644
--- a/symbol.c
+++ b/symbol.c
@@ -505,7 +505,7 @@ static VALUE
dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding * const enc, const ID type)
{
const VALUE dsym = rb_newobj_of(klass, T_SYMBOL | FL_WB_PROTECTED);
- st_index_t hashval;
+ long hashval;
rb_enc_associate(dsym, enc);
OBJ_FREEZE(dsym);
@@ -513,9 +513,8 @@ dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding * const enc, const
RSYMBOL(dsym)->id = type;
/* we want hashval to be in Fixnum range [ruby-core:15713] r15672 */
- hashval = rb_str_hash(str);
- hashval <<= 1;
- RSYMBOL(dsym)->hashval = (st_index_t)RSHIFT(hashval, 1);
+ hashval = (long)rb_str_hash(str);
+ RSYMBOL(dsym)->hashval = RSHIFT((long)hashval, 1);
register_sym(str, dsym);
rb_hash_aset(global_symbols.dsymbol_fstr_hash, str, Qtrue);