Skip to content

Commit

Permalink
Fix a memory leak in tls_new_record_layer
Browse files Browse the repository at this point in the history
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 #21668

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21753)
  • Loading branch information
mattcaswell authored and t8m committed Aug 17, 2023
1 parent 4a469cb commit 0577dba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ssl/record/methods/tls_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0577dba

Please sign in to comment.