From bab37f69d99cd14d64799dc6c4749d83a062e6d9 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Wed, 18 Feb 2026 14:25:41 +0000 Subject: [PATCH] Fix mbedtls_test_free_handshake_options We usually follow the pattern that a zero-initialised struct is safe to free. This wasn't the case here. Signed-off-by: Janos Follath --- tests/src/test_helpers/ssl_helpers.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/src/test_helpers/ssl_helpers.c b/tests/src/test_helpers/ssl_helpers.c index 83dac17419..db29413de6 100644 --- a/tests/src/test_helpers/ssl_helpers.c +++ b/tests/src/test_helpers/ssl_helpers.c @@ -99,8 +99,10 @@ void mbedtls_test_free_handshake_options( mbedtls_test_handshake_test_options *opts) { #if defined(MBEDTLS_SSL_CACHE_C) - mbedtls_ssl_cache_free(opts->cache); - mbedtls_free(opts->cache); + if (opts->cache != NULL) { + mbedtls_ssl_cache_free(opts->cache); + mbedtls_free(opts->cache); + } #else (void) opts; #endif