From 05dc9f0449800c43ecc69d973306a7cc20351fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Frauenschl=C3=A4ger?= Date: Thu, 8 Jan 2026 16:50:28 +0100 Subject: [PATCH] Fix memory leak in case of handshake error Make sure peer dilithium key is properly freed in case the handshakes fails. --- src/internal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/internal.c b/src/internal.c index 49020d3d4..629da7c82 100644 --- a/src/internal.c +++ b/src/internal.c @@ -8711,6 +8711,10 @@ void wolfSSL_ResourceFree(WOLFSSL* ssl) } #endif #endif +#if defined(HAVE_DILITHIUM) + FreeKey(ssl, DYNAMIC_TYPE_DILITHIUM, (void**)&ssl->peerDilithiumKey); + ssl->peerDilithiumKeyPresent = 0; +#endif #if defined(HAVE_FALCON) FreeKey(ssl, DYNAMIC_TYPE_FALCON, (void**)&ssl->peerFalconKey); ssl->peerFalconKeyPresent = 0;