From: Dr. Stephen Henson Date: Fri, 6 Jan 2017 13:12:17 +0000 (+0000) Subject: free str on error X-Git-Tag: OpenSSL_1_1_1-pre1~2754 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=285c7d9cdf3fb917be3361df73aae29e9e732298;p=oweals%2Fopenssl.git free str on error Reviewed-by: Rich Salz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/2177) --- diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c index 9b4300b2d7..810d24f4e6 100644 --- a/crypto/rsa/rsa_ameth.c +++ b/crypto/rsa/rsa_ameth.c @@ -155,12 +155,14 @@ static int rsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) if (rklen <= 0) { RSAerr(RSA_F_RSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); + ASN1_STRING_free(str); return 0; } if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(pkey->ameth->pkey_id), 0, strtype, str, rk, rklen)) { RSAerr(RSA_F_RSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); + ASN1_STRING_free(str); return 0; }