Skip to content

Commit 3a450f6

Browse files
authored
Crash fix caused by passing null into a shared_ptr reset (aws#164)
1 parent a3e7577 commit 3a450f6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

source/io/TlsOptions.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,21 @@ namespace Aws
258258
{
259259
if (mode == TlsMode::CLIENT)
260260
{
261-
m_ctx.reset(aws_tls_client_ctx_new(allocator, &options.m_options), aws_tls_ctx_destroy);
261+
aws_tls_ctx *underlying_tls_ctx = aws_tls_client_ctx_new(allocator, &options.m_options);
262+
263+
if (underlying_tls_ctx != NULL)
264+
{
265+
m_ctx.reset(underlying_tls_ctx, aws_tls_ctx_destroy);
266+
}
262267
}
263268
else
264269
{
265-
m_ctx.reset(aws_tls_server_ctx_new(allocator, &options.m_options), aws_tls_ctx_destroy);
270+
aws_tls_ctx *underlying_tls_ctx = aws_tls_server_ctx_new(allocator, &options.m_options);
271+
272+
if (underlying_tls_ctx != NULL)
273+
{
274+
m_ctx.reset(underlying_tls_ctx, aws_tls_ctx_destroy);
275+
}
266276
}
267277

268278
if (!m_ctx)

0 commit comments

Comments
 (0)