From 05556725a2816aecbf87623c959a4a80ee7eb6de Mon Sep 17 00:00:00 2001 From: Ashish Sharma Date: Mon, 28 Jul 2025 14:07:05 +0800 Subject: [PATCH] feat(mbedtls): skip memset ssl buffers with dynamic buffer enabled. As with dynamic buffer feature enabled, the buffers are handled dynamically, there is no need to memset these on connection reset. This can help to save some heap memory allocation. --- library/ssl_tls.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index b5bea7521..18e1ccbdf 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -1468,6 +1468,12 @@ void mbedtls_ssl_session_reset_msg_layer(mbedtls_ssl_context *ssl, #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH) size_t in_buf_len = ssl->in_buf_len; size_t out_buf_len = ssl->out_buf_len; +/* ESP Change: For dynamic buffer feature, the buffer allocation shall be + * handled on-demand basis and hence skip the memset in this API on the buffer pointers + */ +#elif defined(CONFIG_MBEDTLS_DYNAMIC_BUFFER) + size_t in_buf_len = 0; + size_t out_buf_len = 0; #else size_t in_buf_len = MBEDTLS_SSL_IN_BUFFER_LEN; size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN;