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:
Yukihiro "Matz" Matsumoto
2022-07-29 10:14:05 +09:00
parent 64ea7f0930
commit 5df3f8221d
+1
View File
@@ -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);