From 455187442fe79450a6105575e6b7453a371deb22 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 10 Nov 2023 13:40:22 +0000 Subject: [PATCH] fixup! Move freeing of an old enc_write_ctx/write_hash to dtls1_clear_sent_buffer --- ssl/ssl_lib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 687cb162f85db..9f76564648dbb 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -1212,8 +1212,6 @@ void SSL_free(SSL *s) SSL_SESSION_free(s->psksession); OPENSSL_free(s->psksession_id); - clear_ciphers(s); - ssl_cert_free(s->cert); OPENSSL_free(s->shared_sigalgs); /* Free up if allocated */ @@ -1249,6 +1247,12 @@ void SSL_free(SSL *s) if (s->method != NULL) s->method->ssl_free(s); + /* + * Must occur after s->method->ssl_free(). The DTLS sent_messages queue + * may reference the EVP_CIPHER_CTX/EVP_MD_CTX that are freed here. + */ + clear_ciphers(s); + SSL_CTX_free(s->ctx); ASYNC_WAIT_CTX_free(s->waitctx);