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:
Yukihiro "Matz" Matsumoto
2022-07-26 00:13:15 +09:00
parent e8ce82bf31
commit 26ce85bd5d
+1
View File
@@ -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];