Skip to content

Commit

Permalink
Throw if MVM_is_prime called with too many rounds
Browse files Browse the repository at this point in the history
Valid range is 0..PRIME_SIZE (defined in libtommath).
  • Loading branch information
MasterDuke17 committed Jul 2, 2019
1 parent d6f9e02 commit 0e7599e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/math/bigintops.c
Expand Up @@ -1203,8 +1203,10 @@ MVMint64 MVM_bigint_is_prime(MVMThreadContext *tc, MVMObject *a, MVMint64 b) {
return 0;
}
else {
int result;
mp_prime_is_prime(ia, b, &result);
int result, err;
err = mp_prime_is_prime(ia, b, &result);
if (err != MP_OKAY)
MVM_exception_throw_adhoc(tc, "Invalid number of rounds (%ld), valid range is 0..%d\n", b, PRIME_SIZE);
return result;
}
} else {
Expand Down

0 comments on commit 0e7599e

Please sign in to comment.