From 7f12c0884f6fc87ada262a19b870d9fafced2f07 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 31 Jan 2023 00:57:57 +1100 Subject: [PATCH] Call OSSL_STORE_INFO_free on error path --- lib/dns/openssl_link.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c index 3ec31330da..017e5d6977 100644 --- a/lib/dns/openssl_link.c +++ b/lib/dns/openssl_link.c @@ -301,19 +301,23 @@ dst__openssl_fromlabel_provider(int key_base_id, const char *engine, switch (OSSL_STORE_INFO_get_type(info)) { case OSSL_STORE_INFO_PKEY: if (*ppriv != NULL) { + OSSL_STORE_INFO_free(info); DST_RET(DST_R_INVALIDPRIVATEKEY); } *ppriv = OSSL_STORE_INFO_get1_PKEY(info); if (EVP_PKEY_get_base_id(*ppriv) != key_base_id) { + OSSL_STORE_INFO_free(info); DST_RET(DST_R_BADKEYTYPE); } break; case OSSL_STORE_INFO_PUBKEY: if (*ppub != NULL) { + OSSL_STORE_INFO_free(info); DST_RET(DST_R_INVALIDPUBLICKEY); } *ppub = OSSL_STORE_INFO_get1_PUBKEY(info); if (EVP_PKEY_get_base_id(*ppub) != key_base_id) { + OSSL_STORE_INFO_free(info); DST_RET(DST_R_BADKEYTYPE); } break;