From 3cfa8bae508ac1f95840f44186d8404febe9de2b Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Fri, 12 Dec 2025 15:59:02 +0100 Subject: [PATCH] Add session ref-counting and clean up TLS resume client - Switch to wolfSSL_get1_session() to take a reference to the session - Explicitly null out ssl after free to avoid double-free on exit path - Always free WOLFSSL_SESSION regardless of OPENSSL_EXTRA define --- tls/client-tls-resume.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tls/client-tls-resume.c b/tls/client-tls-resume.c index 02e11814..07827d24 100644 --- a/tls/client-tls-resume.c +++ b/tls/client-tls-resume.c @@ -174,14 +174,14 @@ int main(int argc, char** argv) /* Save the session */ - session = wolfSSL_get_session(ssl); + session = wolfSSL_get1_session(ssl); /* Close the socket */ wolfSSL_free(ssl); + ssl = NULL; close(sockfd); - /* --------------------------------------- * * we are now disconnected from the server * * --------------------------------------- */ @@ -275,10 +275,8 @@ exit: /* Cleanup and return */ if (ssl) wolfSSL_free(ssl); /* Free the wolfSSL object */ -#ifdef OPENSSL_EXTRA if (session) wolfSSL_SESSION_free(session); -#endif if (sockfd != SOCKET_INVALID) close(sockfd); /* Close the socket */ if (ctx)