Fix ubsan runtime error due to large shift

This commit is contained in:
Paulo Matos 2018-10-02 22:02:00 +02:00 committed by Matthew Flatt
parent 15523f68ec
commit 5bbbe44a7b

View File

@ -5477,8 +5477,8 @@ static Scheme_Object *fold_fixnum_bitwise_shift(int argc, Scheme_Object *argv[])
base = SCHEME_INT_VAL(argv[0]);
/* Consistent if potentially unkept bits are all 0 or 1 */
if (!(base - (base & ((1 << kept) - 1)))
|| !(~(base | ((1 << kept) - 1)))) {
if (!(base - (base & ((1UL << kept) - 1)))
|| !(~(base | ((1UL << kept) - 1)))) {
v = base << amt;
return scheme_make_integer(v);