aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/hmac
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@ghedini.me>2015-10-08 14:38:57 +0200
committerRichard Levitte <levitte@openssl.org>2015-10-23 19:52:08 +0200
commit3f6c7691870d1cd2ad0e0c83638cef3f35a0b548 (patch)
treef0dae5a5fabb3b68e94d748ca49f4262411fad7a /crypto/hmac
parent8acaabec429b39f9436f6a88006384d72d292539 (diff)
downloadopenssl-3f6c7691870d1cd2ad0e0c83638cef3f35a0b548.tar.gz
Fix memory leaks and other mistakes on errors
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/hmac')
-rw-r--r--crypto/hmac/hm_ameth.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/crypto/hmac/hm_ameth.c b/crypto/hmac/hm_ameth.c
index cd29c0ccd8..20abe4f087 100644
--- a/crypto/hmac/hm_ameth.c
+++ b/crypto/hmac/hm_ameth.c
@@ -108,9 +108,14 @@ static int old_hmac_decode(EVP_PKEY *pkey,
ASN1_OCTET_STRING *os;
os = ASN1_OCTET_STRING_new();
if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen))
- return 0;
- EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os);
+ goto err;
+ if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))
+ goto err;
return 1;
+
+ err:
+ ASN1_OCTET_STRING_free(os);
+ return 0;
}
static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder)