diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-12-31 08:39:20 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-12-31 12:11:45 +0900 |
commit | 20a8425aa0f9a947e72b06cbd3a2afe9674dd18f (patch) | |
tree | a6f86987877303b2ae99be64334265377f7fa453 /hash.c | |
parent | b2030d4dae3142e3fe6ad79ac1202de5a9f34a5a (diff) |
Make any hash values fixable [Bug #17488]
As hnum is an unsigned st_index_t, the result of RSHIFT may not be
in the fixable range.
Co-authored-by: NeoCat <[email protected]>
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 11 |
1 files changed, 3 insertions, 8 deletions
@@ -223,15 +223,10 @@ any_hash(VALUE a, st_index_t (*other_func)(VALUE)) default: hnum = other_func(a); } -#if SIZEOF_LONG < SIZEOF_ST_INDEX_T - if (hnum > 0) - hnum &= (unsigned long)-1 >> 2; + if ((SIGNED_VALUE)hnum > 0) + hnum &= FIXNUM_MAX; else - hnum |= ~((unsigned long)-1 >> 2); -#else - hnum <<= 1; - hnum = RSHIFT(hnum, 1); -#endif + hnum |= FIXNUM_MIN; return (long)hnum; } |