From 4434328b0ab664ae3d6cb4a97aad38d6ea9b9e06 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 12 Nov 2009 19:57:39 +0000 Subject: [PATCH] PR: 2088 Submitted by: Aleksey Samsonov Approved by: steve@openssl.org Fix memory leak in d2i_PublicKey(). --- crypto/asn1/d2i_pu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crypto/asn1/d2i_pu.c b/crypto/asn1/d2i_pu.c index 3694f51a8c..c8f39ceb03 100644 --- a/crypto/asn1/d2i_pu.c +++ b/crypto/asn1/d2i_pu.c @@ -87,9 +87,13 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, } else ret= *a; - ret->save_type=type; - ret->type=EVP_PKEY_type(type); - switch (ret->type) + if (!EVP_PKEY_set_type(ret, type)) + { + ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_EVP_LIB); + goto err; + } + + switch (EVP_PKEY_id(ret)) { #ifndef OPENSSL_NO_RSA case EVP_PKEY_RSA: -- 2.25.1