Fix a memory leak in tls1_mac
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 16 Mar 2018 20:36:48 +0000 (21:36 +0100)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Sat, 17 Mar 2018 07:29:45 +0000 (08:29 +0100)
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5651)

ssl/record/ssl3_record.c

index f6e59d2f8421378470e1af4a126bd6e6f20144e0..6e1ff3f5630e422ca4f685f9cd96419126c2199e 100644 (file)
@@ -988,8 +988,10 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int sending)
         mac_ctx = hash;
     } else {
         hmac = EVP_MD_CTX_new();
-        if (hmac == NULL || !EVP_MD_CTX_copy(hmac, hash))
+        if (hmac == NULL || !EVP_MD_CTX_copy(hmac, hash)) {
+            EVP_MD_CTX_free(hmac);
             return -1;
+        }
         mac_ctx = hmac;
     }