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

ssl/record/ssl3_record.c

index 4ffc84279d62b6e213d837aa7c14ad6aefe8bd88..fa902f30fbb4befcd00c0feec9d99f3ca356a275 100644 (file)
@@ -1297,8 +1297,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 0;
+        }
         mac_ctx = hmac;
     }