From 0577dbad0709f1b3717297420069c6160245e74d Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 16 Aug 2023 12:15:07 +0100 Subject: [PATCH] Fix a memory leak in tls_new_record_layer If setting the crypto state has failed then memory might have been partially allocated to fields within the partially constructed record layer. We need to call tls_int_free() to properly free it. Found by the reproducible error patch in openssl#21668 Reviewed-by: Todd Short Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/21753) --- ssl/record/methods/tls_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssl/record/methods/tls_common.c b/ssl/record/methods/tls_common.c index 4cfeddca431..505e1331618 100644 --- a/ssl/record/methods/tls_common.c +++ b/ssl/record/methods/tls_common.c @@ -1411,7 +1411,7 @@ tls_new_record_layer(OSSL_LIB_CTX *libctx, const char *propq, int vers, err: if (ret != OSSL_RECORD_RETURN_SUCCESS) { - OPENSSL_free(*retrl); + tls_int_free(*retrl); *retrl = NULL; } return ret; -- 2.47.2