From: Nils Larsch Date: Mon, 13 Mar 2006 23:12:08 +0000 (+0000) Subject: fix error found by coverity: check if ctx is != NULL before calling BN_CTX_end() X-Git-Tag: OpenSSL_0_9_8b~13 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b7a80146f45dc47ee2a7e33298d1fa4c7110cca4;p=oweals%2Fopenssl.git fix error found by coverity: check if ctx is != NULL before calling BN_CTX_end() --- diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index cc17c8851b..79984e13bc 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -217,8 +217,11 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) ret=BN_bn2bin(tmp,key); err: - BN_CTX_end(ctx); - BN_CTX_free(ctx); + if (ctx != NULL) + { + BN_CTX_end(ctx); + BN_CTX_free(ctx); + } return(ret); } diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c index a9f7c9d378..5cd1eac41f 100644 --- a/crypto/ec/ec2_smpl.c +++ b/crypto/ec/ec2_smpl.c @@ -281,7 +281,8 @@ int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) ret = 1; err: - BN_CTX_end(ctx); + if (ctx != NULL) + BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; diff --git a/crypto/ec/ec_check.c b/crypto/ec/ec_check.c index f22c5641a8..0e316b4b3f 100644 --- a/crypto/ec/ec_check.c +++ b/crypto/ec/ec_check.c @@ -113,7 +113,8 @@ int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx) ret = 1; err: - BN_CTX_end(ctx); + if (ctx != NULL) + BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); if (point) diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c index 75296a3673..4d26f8bdf6 100644 --- a/crypto/ec/ecp_smpl.c +++ b/crypto/ec/ecp_smpl.c @@ -336,7 +336,8 @@ int ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) ret = 1; err: - BN_CTX_end(ctx); + if (ctx != NULL) + BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c index 383d6095f5..742f8b18e5 100644 --- a/crypto/rsa/rsa_gen.c +++ b/crypto/rsa/rsa_gen.c @@ -183,8 +183,11 @@ err: RSAerr(RSA_F_RSA_BUILTIN_KEYGEN,ERR_LIB_BN); ok=0; } - BN_CTX_end(ctx); - BN_CTX_free(ctx); + if (ctx != NULL) + { + BN_CTX_end(ctx); + BN_CTX_free(ctx); + } return ok; }