From e6e9170d6e28038768895e1af18e3aad8093bf4b Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Tue, 27 Mar 2018 16:25:08 -0400 Subject: 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 (Merged from https://github.com/openssl/openssl/pull/5761) --- crypto/bn/bn_mont.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'crypto/bn/bn_mont.c') 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); } -- cgit v1.2.3