Fix memory leak.

The function reset_checksum() can be called more than once with the same
handshake context (this happens with DTLS clients, and perhaps in other
cases as well). When that happens, we need to free the old MD contexts
before setting them up again.

Note: the PSA path was already doing the right thing by calling abort,
we just needed to do the same on the MD path.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 9070f20..8ee1ddc 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -839,6 +839,8 @@
         return mbedtls_md_error_from_psa(status);
     }
 #else
+    mbedtls_md_free(&ssl->handshake->fin_sha256);
+    mbedtls_md_init(&ssl->handshake->fin_sha256);
     ret = mbedtls_md_setup(&ssl->handshake->fin_sha256,
                            mbedtls_md_info_from_type(MBEDTLS_MD_SHA256),
                            0);
@@ -862,6 +864,8 @@
         return mbedtls_md_error_from_psa(status);
     }
 #else
+    mbedtls_md_free(&ssl->handshake->fin_sha384);
+    mbedtls_md_init(&ssl->handshake->fin_sha384);
     ret = mbedtls_md_setup(&ssl->handshake->fin_sha384,
                            mbedtls_md_info_from_type(MBEDTLS_MD_SHA384), 0);
     if (ret != 0) {