diff options
-rw-r--r-- | lib.h | 4 | ||||
-rw-r--r-- | mpi/mpi.c | 46 | ||||
-rw-r--r-- | regex.c | 3 |
3 files changed, 29 insertions, 24 deletions
@@ -491,7 +491,11 @@ INLINE wchar_t *litptr(val obj) INLINE val num_fast(cnum n) { +#if HAVE_UBSAN + return coerce(val, (n * (1 << TAG_SHIFT)) | TAG_NUM); +#else return coerce(val, (n << TAG_SHIFT) | TAG_NUM); +#endif } INLINE mp_int *mp(val bign) @@ -3385,35 +3385,35 @@ mp_err s_mp_mul_2d(mp_int *mp, mp_digit d) return res; dp = DIGITS(mp); used = USED(mp); - d %= DIGIT_BIT; - mask = (convert(mp_digit, 1) << d) - 1; + if ((d %= DIGIT_BIT) != 0) { + mask = (convert(mp_digit, 1) << d) - 1; - /* If the shift requires another digit, make sure we've got one to - work with */ - if ((dp[used - 1] >> (DIGIT_BIT - d)) & mask) { - if ((res = s_mp_grow(mp, used + 1)) != MP_OKAY) - return res; - dp = DIGITS(mp); - } + /* If the shift requires another digit, make sure we've got one to + work with */ + if ((dp[used - 1] >> (DIGIT_BIT - d)) & mask) { + if ((res = s_mp_grow(mp, used + 1)) != MP_OKAY) + return res; + dp = DIGITS(mp); + } - /* Do the shifting... */ - save = 0; - for (ix = 0; ix < used; ix++) { - next = (dp[ix] >> (DIGIT_BIT - d)) & mask; - dp[ix] = (dp[ix] << d) | save; - save = next; - } + /* Do the shifting... */ + save = 0; + for (ix = 0; ix < used; ix++) { + next = (dp[ix] >> (DIGIT_BIT - d)) & mask; + dp[ix] = (dp[ix] << d) | save; + save = next; + } - /* If, at this point, we have a nonzero carryout into the next - * digit, we'll increase the size by one digit, and store it... - */ - if (save) { - dp[used] = save; - USED(mp) += 1; + /* If, at this point, we have a nonzero carryout into the next + * digit, we'll increase the size by one digit, and store it... + */ + if (save) { + dp[used] = save; + USED(mp) += 1; + } } - s_mp_clamp(mp); return MP_OKAY; } @@ -300,7 +300,8 @@ static void L0_fill_range(cset_L0_t *L0, wchar_t ch0, wchar_t ch1) static int L0_contains(cset_L0_t *L0, wchar_t ch) { - return ((*L0)[CHAR_SET_INDEX(ch)] & (1 << CHAR_SET_BIT(ch))) != 0; + return ((*L0)[CHAR_SET_INDEX(ch)] & + (convert(bitcell_t, 1) << CHAR_SET_BIT(ch))) != 0; } static int L1_full(cset_L1_t *L1) |