fix memory leak issue

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2021-10-30 11:54:10 +08:00
parent 47413c2c8f
commit ba9c727e94

View file

@ -5477,8 +5477,15 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl )
psa_destroy_key( handshake->ecdh_psa_privkey );
#endif /* MBEDTLS_ECDH_C && MBEDTLS_USE_PSA_CRYPTO */
mbedtls_platform_zeroize( handshake,
sizeof( mbedtls_ssl_handshake_params ) );
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
mbedtls_ssl_transform_free(handshake->transform_handshake);
mbedtls_ssl_transform_free(handshake->transform_earlydata);
mbedtls_free( handshake->transform_earlydata );
mbedtls_free( handshake->transform_handshake );
handshake->transform_earlydata = NULL;
handshake->transform_handshake = NULL;
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
/* If the buffers are too big - reallocate. Because of the way Mbed TLS
@ -5489,12 +5496,9 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl )
mbedtls_ssl_get_output_buflen( ssl ) );
#endif
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
mbedtls_free( handshake->transform_earlydata );
mbedtls_free( handshake->transform_handshake );
handshake->transform_earlydata = NULL;
handshake->transform_handshake = NULL;
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
/* mbedtls_platform_zeroize MUST be last one in this function */
mbedtls_platform_zeroize( handshake,
sizeof( mbedtls_ssl_handshake_params ) );
}
void mbedtls_ssl_session_free( mbedtls_ssl_session *session )