Fix a mem leak in evp_pkey_copy_downgraded()
authorMatt Caswell <matt@openssl.org>
Fri, 3 Jun 2022 13:01:22 +0000 (14:01 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 8 Jun 2022 14:28:07 +0000 (15:28 +0100)
commitae4d9573ac783dcf26279f461d42d0e261e978f7
treea89ebd4c6ba63819ddb3c2d1aa08f0a34118d042
parent4c149cf9f6a2ba665d74dbd4cf44f080816c900b
Fix a mem leak in evp_pkey_copy_downgraded()

If we get a failure during evp_pkey_copy_downgraded() and on entry *dest
was NULL then we leak the EVP_PKEY that was automatically allocated and
stored in *dest.

Found due to this comment:
https://github.com/openssl/openssl/pull/18355#issuecomment-1145028315

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18470)
crypto/evp/p_lib.c