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:03:32 +0000 (00:03 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4503)

crypto/evp/pmeth_lib.c

index 31ec09261fd48744cc18583abaf815d03362dea9..35e525b6ed04eb349c008e368be8babb938924c0 100644 (file)
@@ -129,6 +129,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;
     }