Fix memory leak on lookup failure
authorDr. Stephen Henson <steve@openssl.org>
Mon, 9 Oct 2017 22:24:26 +0000 (23:24 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Wed, 11 Oct 2017 23:08:30 +0000 (00:08 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4503)

(cherry picked from commit 918a27facd3558444c69b1edbedb49478e82dff5)

crypto/evp/pmeth_lib.c

index 877fbd072e6554a14a704d1fefc88c5b0aab4aea..77e17dbd17296209cccdef08ca50391cd6722f43 100644 (file)
@@ -113,6 +113,9 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id)
         pmeth = EVP_PKEY_meth_find(id);
 
     if (pmeth == NULL) {
+#ifndef OPENSSL_NO_ENGINE
+        ENGINE_finish(e);
+#endif
         EVPerr(EVP_F_INT_CTX_NEW, EVP_R_UNSUPPORTED_ALGORITHM);
         return NULL;
     }