Fix a memleak in tls13_generate_secret.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3660)
This commit is contained in:
Bernd Edlinger 2017-06-12 19:30:10 +02:00 committed by Rich Salz
parent 5816586ba4
commit 71d8c138cf

View file

@ -148,6 +148,7 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md,
|| EVP_DigestInit_ex(mctx, md, NULL) <= 0
|| EVP_DigestFinal_ex(mctx, hash, NULL) <= 0) {
EVP_MD_CTX_free(mctx);
EVP_PKEY_CTX_free(pctx);
return 0;
}
EVP_MD_CTX_free(mctx);
@ -156,8 +157,10 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md,
if (!tls13_hkdf_expand(s, md, prevsecret,
(unsigned char *)derived_secret_label,
sizeof(derived_secret_label) - 1, hash,
preextractsec, mdlen))
preextractsec, mdlen)) {
EVP_PKEY_CTX_free(pctx);
return 0;
}
prevsecret = preextractsec;
prevsecretlen = mdlen;