summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_mont.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2018-03-27 16:25:08 -0400
committerRich Salz <rsalz@openssl.org>2018-03-27 16:25:08 -0400
commite6e9170d6e28038768895e1af18e3aad8093bf4b (patch)
tree62f594f0968ff8d6c27795377a102e4aab373b00 /crypto/bn/bn_mont.c
parent98c03302fb7b855647aa14022f61f5fb272e514a (diff)
Allow NULL for some _free routines.
Based on the description in https://github.com/openssl/openssl/pull/5757, this re-implements the "allow NULL to be passed" behavior of a number of xxx_free routines. I also fixed up some egregious formatting errors that were nearby. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5761)
Diffstat (limited to 'crypto/bn/bn_mont.c')
-rw-r--r--crypto/bn/bn_mont.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c
index bae7d235bd..c882891d5e 100644
--- a/crypto/bn/bn_mont.c
+++ b/crypto/bn/bn_mont.c
@@ -208,18 +208,20 @@ BN_MONT_CTX *BN_MONT_CTX_new(void)
void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
{
ctx->ri = 0;
- bn_init(&(ctx->RR));
- bn_init(&(ctx->N));
- bn_init(&(ctx->Ni));
+ bn_init(&ctx->RR);
+ bn_init(&ctx->N);
+ bn_init(&ctx->Ni);
ctx->n0[0] = ctx->n0[1] = 0;
ctx->flags = 0;
}
void BN_MONT_CTX_free(BN_MONT_CTX *mont)
{
- BN_clear_free(&(mont->RR));
- BN_clear_free(&(mont->N));
- BN_clear_free(&(mont->Ni));
+ if (mont == NULL)
+ return;
+ BN_clear_free(&mont->RR);
+ BN_clear_free(&mont->N);
+ BN_clear_free(&mont->Ni);
if (mont->flags & BN_FLG_MALLOCED)
OPENSSL_free(mont);
}