Scan-Build Fixes

1. Fix a potential dereference of NULL pointer.

To recreate:
    $ scan-build ./configure --enable-sp --enable-sp-asm --enable-sp-math
This commit is contained in:
John Safranek
2020-11-12 11:33:42 -08:00
parent b931b1bd4d
commit 1e348b991d

View File

@@ -2321,10 +2321,12 @@ int sp_prime_is_prime_ex(sp_int* a, int t, int* result, WC_RNG* rng)
if (a == NULL || result == NULL || rng == NULL)
err = MP_VAL;
if (err == MP_OKAY) {
if (sp_isone(a)) {
*result = MP_NO;
return MP_OKAY;
}
}
if (err == MP_OKAY && a->used == 1) {
/* check against primes table */
@@ -2410,6 +2412,7 @@ int sp_prime_is_prime_ex(sp_int* a, int t, int* result, WC_RNG* rng)
(void)t;
#endif /* !WC_NO_RNG */
if (result != NULL)
*result = ret;
return err;
}