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 4ffc842..fa902f3 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;
     }