summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-12-19 15:42:58 +1100
committerDamien George <damien.p.george@gmail.com>2017-12-19 15:42:58 +1100
commit374eaf5271c9bfc63b5aa1139de55753ad67cc9a (patch)
treeea9311d73a049d0cd5188ad1531ea9c9a286935f /py
parent8e6113a18808792c5d1eb30e54bb0a1694bb4042 (diff)
py/mpz: Fix pow3 function so it handles the case when 3rd arg is 1.
In this case the result should always be 0, even if 2nd arg is 0.
Diffstat (limited to 'py')
-rw-r--r--py/mpz.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/mpz.c b/py/mpz.c
index d300a8e5d..16112c201 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -1390,7 +1390,7 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
can have dest, lhs, rhs the same; mod can't be the same as dest
*/
void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod) {
- if (lhs->len == 0 || rhs->neg != 0) {
+ if (lhs->len == 0 || rhs->neg != 0 || (mod->len == 1 && mod->dig[0] == 1)) {
mpz_set_from_int(dest, 0);
return;
}