summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-05-03 16:05:31 +0200
committerDr. Stephen Henson <steve@openssl.org>2016-05-04 13:57:41 +0200
commit3340e8bb186f689df5720352f65a9c0c42b6046b (patch)
tree118de654e6734d54c0be3a44a8f578073f83b92d /crypto
parentGH932: Add more help messages to some apps options. (diff)
downloadopenssl-3340e8bb186f689df5720352f65a9c0c42b6046b.tar.xz
openssl-3340e8bb186f689df5720352f65a9c0c42b6046b.zip
Fix double free in d2i_PrivateKey().
RT#4527 Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/asn1/d2i_pr.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/asn1/d2i_pr.c b/crypto/asn1/d2i_pr.c
index 85567cee5c..48a845f8b7 100644
--- a/crypto/asn1/d2i_pr.c
+++ b/crypto/asn1/d2i_pr.c
@@ -93,15 +93,17 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
if (!ret->ameth->old_priv_decode ||
!ret->ameth->old_priv_decode(ret, &p, length)) {
if (ret->ameth->priv_decode) {
+ EVP_PKEY *tmp;
PKCS8_PRIV_KEY_INFO *p8 = NULL;
p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, length);
if (!p8)
goto err;
- EVP_PKEY_free(ret);
- ret = EVP_PKCS82PKEY(p8);
+ tmp = EVP_PKCS82PKEY(p8);
PKCS8_PRIV_KEY_INFO_free(p8);
- if (ret == NULL)
+ if (tmp == NULL)
goto err;
+ EVP_PKEY_free(ret);
+ ret = tmp;
} else {
ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB);
goto err;