Skip to content
Snippets Groups Projects
Commit 6a8c7d67 authored by Niels Möller's avatar Niels Möller
Browse files

* modules/Gmp/next_prime.c (mpz_next_prime): Fixed off-by-one

overflow.

Rev: src/modules/Gmp/next_prime.c:1.9
parent 3681ea40
No related branches found
No related tags found
No related merge requests found
/* $Id: next_prime.c,v 1.8 1998/07/11 16:24:00 grubba Exp $
/* $Id: next_prime.c,v 1.9 1999/03/11 16:01:09 nisse Exp $
*
* Prime number test using trial division for small primes and then
* Miller-Rabin, as suggested in Schneier's Applied Cryptography.
......@@ -9,7 +9,7 @@
#include "global.h"
RCSID("$Id: next_prime.c,v 1.8 1998/07/11 16:24:00 grubba Exp $");
RCSID("$Id: next_prime.c,v 1.9 1999/03/11 16:01:09 nisse Exp $");
#include "gmp_machine.h"
......@@ -177,7 +177,7 @@ mpz_next_prime(mpz_t p, mpz_t n, int count, int prime_limit)
if (prime_limit)
{
/* Compute residues modulo small odd primes */
moduli = (unsigned long*) alloca((prime_limit -1) * sizeof(*moduli));
moduli = (unsigned long*) alloca(prime_limit * sizeof(*moduli));
for (i = 0; i < prime_limit; i++)
moduli[i] = mpz_fdiv_ui(p, primes[i + 1]);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment