summaryrefslogtreecommitdiff
path: root/mpz/invert.c
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2012-02-24 17:40:57 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2012-02-24 17:40:57 +0100
commitbef2a8f26b2b42fe2be47c34d472435117bae9ac (patch)
tree1b5817c93f1f44e37484a6f48dc5c0b47f8514d4 /mpz/invert.c
parent20816efe8a2c6127c7d3acda57d8485448bfbe10 (diff)
downloadgmp-bef2a8f26b2b42fe2be47c34d472435117bae9ac.tar.gz
mpz_invert: return 0 (no-inverse) when modulus is zero.
Diffstat (limited to 'mpz/invert.c')
-rw-r--r--mpz/invert.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mpz/invert.c b/mpz/invert.c
index 3a32b4c91..ec2e1184a 100644
--- a/mpz/invert.c
+++ b/mpz/invert.c
@@ -34,8 +34,8 @@ mpz_invert (mpz_ptr inverse, mpz_srcptr x, mpz_srcptr n)
nsize = ABSIZ (n);
/* No inverse exists if the leftside operand is 0. Likewise, no
- inverse exists if the mod operand is 1. */
- if (xsize == 0 || (nsize == 1 && (PTR (n))[0] == 1))
+ inverse exists if the mod operand is 1 or 0. */
+ if (xsize == 0 || nsize == 0 || (nsize == 1 && (PTR (n))[0] == 1))
return 0;
size = MAX (xsize, nsize) + 1;