mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
bigint.c (lzb): check x==0 before calling clz().
In theory, we should not call lzb() with 0, and we assume checks are done before calling it. But we got a report that we call lzb(0) in some use-case. We could not reproduce the issue, so we add this guard.
This commit is contained in:
@@ -350,6 +350,7 @@ mpz_mul_int(mrb_state *mrb, mpz_t *x, mpz_t *y, mrb_int n)
|
||||
static int
|
||||
lzb(mp_limb x)
|
||||
{
|
||||
if (x == 0) return 0;
|
||||
#if (defined(__GNUC__) || __has_builtin(__builtin_clz))
|
||||
if (sizeof(mp_limb) == sizeof(int64_t))
|
||||
return __builtin_clzll(x);
|
||||
|
||||
Reference in New Issue
Block a user