mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
bigint.c (ucmp): fixed error with zero length zero value.
Big integers have two kind of zero values: - digits in `p` array are all zeros - length `sn` is zero The old code crashed with the latter zero.
This commit is contained in:
@@ -186,6 +186,7 @@ ucmp(mpz_t *y, mpz_t *x)
|
||||
{
|
||||
if (y->sz < x->sz) return -1;
|
||||
if (y->sz > x->sz) return 1;
|
||||
if (x->sz == 0) return 0;
|
||||
for (size_t i=x->sz-1;; i--) {
|
||||
mp_limb a = y->p[i];
|
||||
mp_limb b = x->p[i];
|
||||
|
||||
Reference in New Issue
Block a user