GH1537: Avoid double-free in the EVP_PKEY API

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Alex Gaynor 2016-09-07 09:41:20 -04:00 committed by Rich Salz
parent 01c09f9fde
commit d65c3615f6

View File

@ -398,6 +398,7 @@ void EVP_PKEY_free(EVP_PKEY *x)
return;
REF_ASSERT_ISNT(i < 0);
EVP_PKEY_free_it(x);
CRYPTO_THREAD_lock_free(x->lock);
sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
OPENSSL_free(x);
}
@ -413,7 +414,6 @@ static void EVP_PKEY_free_it(EVP_PKEY *x)
ENGINE_finish(x->engine);
x->engine = NULL;
#endif
CRYPTO_THREAD_lock_free(x->lock);
}
static int unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent,