Fix CID 1466710 : Resource leak in ec_kmgmt due to new call to ossl_prov_is_running()
authorShane Lontis <shane.lontis@oracle.com>
Mon, 21 Sep 2020 01:39:04 +0000 (11:39 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Wed, 23 Sep 2020 07:16:39 +0000 (17:16 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12930)

providers/implementations/keymgmt/ec_kmgmt.c

index 63c51af3a1956c0334ad9a81220d3d178395725d..2a8980ddf5221cd606fed98b2045911878932421 100644 (file)
@@ -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)