MbedTLS: Move memory allocation to the beginning of rb_ssl_init_fd
This commit is contained in:
parent
163a4a9d06
commit
978c8ae828
1 changed files with 9 additions and 9 deletions
|
@ -121,6 +121,15 @@ rb_mbedtls_cfg_decref(rb_mbedtls_cfg_context *const cfg)
|
|||
static void
|
||||
rb_ssl_init_fd(rb_fde_t *const F, rb_fd_tls_direction dir)
|
||||
{
|
||||
rb_mbedtls_ssl_context *const mbed_ssl_ctx = rb_malloc(sizeof *mbed_ssl_ctx);
|
||||
|
||||
if(mbed_ssl_ctx == NULL)
|
||||
{
|
||||
rb_lib_log("rb_ssl_init_fd: rb_malloc: allocation failure");
|
||||
rb_close(F);
|
||||
return;
|
||||
}
|
||||
|
||||
mbedtls_ssl_config *mbed_config;
|
||||
|
||||
switch(dir)
|
||||
|
@ -133,15 +142,6 @@ rb_ssl_init_fd(rb_fde_t *const F, rb_fd_tls_direction dir)
|
|||
break;
|
||||
}
|
||||
|
||||
rb_mbedtls_ssl_context *const mbed_ssl_ctx = rb_malloc(sizeof *mbed_ssl_ctx);
|
||||
|
||||
if(mbed_ssl_ctx == NULL)
|
||||
{
|
||||
rb_lib_log("rb_ssl_init_fd: rb_malloc: allocation failure");
|
||||
rb_close(F);
|
||||
return;
|
||||
}
|
||||
|
||||
mbedtls_ssl_init(&mbed_ssl_ctx->ssl);
|
||||
mbedtls_ssl_set_bio(&mbed_ssl_ctx->ssl, F, rb_sock_net_xmit, rb_sock_net_recv, NULL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue