Skip to content

Commit 8d7a201

Browse files
authored
Fix a memory leak from error handling in s2n tls hanlder. (#753)
1 parent ba5cb6d commit 8d7a201

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

source/s2n/s2n_tls_channel_handler.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,18 +1450,15 @@ static struct aws_tls_ctx *s_tls_ctx_new(
14501450
struct aws_allocator *alloc,
14511451
const struct aws_tls_ctx_options *options,
14521452
s2n_mode mode) {
1453-
struct s2n_ctx *s2n_ctx = aws_mem_calloc(alloc, 1, sizeof(struct s2n_ctx));
1454-
1455-
if (!s2n_ctx) {
1456-
return NULL;
1457-
}
14581453

14591454
if (!aws_tls_is_cipher_pref_supported(options->cipher_pref)) {
14601455
aws_raise_error(AWS_IO_TLS_CIPHER_PREF_UNSUPPORTED);
14611456
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "static: TLS Cipher Preference is not supported: %d.", options->cipher_pref);
14621457
return NULL;
14631458
}
14641459

1460+
struct s2n_ctx *s2n_ctx = aws_mem_calloc(alloc, 1, sizeof(struct s2n_ctx));
1461+
14651462
s2n_ctx->ctx.alloc = alloc;
14661463
s2n_ctx->ctx.impl = s2n_ctx;
14671464
aws_ref_count_init(&s2n_ctx->ctx.ref_count, s2n_ctx, (aws_simple_completion_callback *)s_s2n_ctx_destroy);

0 commit comments

Comments
 (0)