X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/f94b972d1c0389e4e9203cc9919ceaadbe655b61..f4535c6454395e6d56ce0091a07b6d4f7d54a47f:/f-niceprime.c diff --git a/f-niceprime.c b/f-niceprime.c index a6191da..ce96977 100644 --- a/f-niceprime.c +++ b/f-niceprime.c @@ -138,7 +138,7 @@ static const field_ops fops = { * * Arguments: @mp *p@ = the characteristic of the field * - * Returns: A pointer to the field. + * Returns: A pointer to the field, or null. * * Use: Creates a field structure for a prime field of size %$p$%, * using efficient reduction for nice primes. @@ -152,7 +152,10 @@ field *field_niceprime(mp *p) f->f.one = MP_ONE; f->f.nbits = mp_bits(p); f->f.noctets = (f->f.nbits + 7) >> 3; - mpreduce_create(&f->r, p); + if (mpreduce_create(&f->r, p)) { + DESTROY(f); + return (0); + } f->f.m = f->r.p; return (&f->f); }