From ced5231b04679dc31ce981d66d08260037fa40d8 Mon Sep 17 00:00:00 2001 From: Shane Lontis Date: Mon, 21 Sep 2020 11:39:04 +1000 Subject: [PATCH] Fix CID 1466710 : Resource leak in ec_kmgmt due to new call to ossl_prov_is_running() Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/12930) --- providers/implementations/keymgmt/ec_kmgmt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c index 63c51af3a19..2a8980ddf52 100644 --- a/providers/implementations/keymgmt/ec_kmgmt.c +++ b/providers/implementations/keymgmt/ec_kmgmt.c @@ -788,9 +788,13 @@ int ec_validate(void *keydata, int selection) { EC_KEY *eck = keydata; int ok = 0; - BN_CTX *ctx = BN_CTX_new_ex(ec_key_get_libctx(eck)); + BN_CTX *ctx = NULL; + + if (!ossl_prov_is_running()) + return 0; - if (!ossl_prov_is_running() || ctx == NULL) + ctx = BN_CTX_new_ex(ec_key_get_libctx(eck)); + if (ctx == NULL) return 0; if ((selection & EC_POSSIBLE_SELECTIONS) != 0) -- 2.47.2