From 218e1263c4f2ac014859bcd6b72d0e66a3f75d95 Mon Sep 17 00:00:00 2001 From: Pauli Date: Mon, 22 Mar 2021 09:05:40 +1000 Subject: [PATCH] ec_keymgmt: fix coverity 1474427: resource leak Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14637) --- providers/implementations/keymgmt/ec_kmgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c index 2ba21dfb391..b8aa518a081 100644 --- a/providers/implementations/keymgmt/ec_kmgmt.c +++ b/providers/implementations/keymgmt/ec_kmgmt.c @@ -847,13 +847,13 @@ int sm2_validate(const void *keydata, int selection, int checktype) if (!ossl_prov_is_running()) return 0; + if ((selection & EC_POSSIBLE_SELECTIONS) == 0) + return 1; /* nothing to validate */ + ctx = BN_CTX_new_ex(ossl_ec_key_get_libctx(eck)); if (ctx == NULL) return 0; - if ((selection & EC_POSSIBLE_SELECTIONS) == 0) - return 1; /* nothing to validate */ - if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) ok = ok && EC_GROUP_check(EC_KEY_get0_group(eck), ctx); -- 2.47.2