*
* 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.
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);
}