Fixed potential memory leak when failing to resume a session
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index fd5b5a3..1574217 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -2345,6 +2345,13 @@
return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE );
}
+ /* In case we tried to reuse a session but it failed */
+ if( ssl->session_negotiate->peer_cert != NULL )
+ {
+ x509_free( ssl->session_negotiate->peer_cert );
+ free( ssl->session_negotiate->peer_cert );
+ }
+
if( ( ssl->session_negotiate->peer_cert = (x509_cert *) malloc(
sizeof( x509_cert ) ) ) == NULL )
{