diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 2e8d5a51c..d2ca1c1a9 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -302,14 +302,13 @@ BOOL rdp_client_connect(rdpRdp* rdp) { UINT32 SelectedProtocol = 0; BOOL status = 0; - rdpSettings* settings = nullptr; /* make sure SSL is initialize for earlier enough for crypto, by taking advantage of winpr SSL * FIPS flag for openssl initialization */ DWORD flags = WINPR_SSL_INIT_DEFAULT; WINPR_ASSERT(rdp); - settings = rdp->settings; + rdpSettings* settings = rdp->settings; WINPR_ASSERT(settings); if (!rdp_client_reset_codecs(rdp->context)) @@ -318,7 +317,9 @@ BOOL rdp_client_connect(rdpRdp* rdp) if (settings->FIPSMode) flags |= WINPR_SSL_INIT_ENABLE_FIPS; - winpr_InitializeSSL(flags); + if (!winpr_InitializeSSL(flags)) + return FALSE; + rdp_log_build_warnings(rdp); /* FIPS Mode forces the following and overrides the following(by happening later */ @@ -353,6 +354,9 @@ BOOL rdp_client_connect(rdpRdp* rdp) const UINT32 port = settings->ServerPort; WINPR_ASSERT(port <= UINT32_MAX); + if (!rdp->nego) + return FALSE; + nego_init(rdp->nego); nego_set_target(rdp->nego, hostname, (UINT16)port); @@ -502,8 +506,11 @@ BOOL rdp_client_disconnect(rdpRdp* rdp) if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_INITIAL)) return FALSE; - if (freerdp_channels_disconnect(context->channels, context->instance) != CHANNEL_RC_OK) - return FALSE; + if (context->channels) + { + if (freerdp_channels_disconnect(context->channels, context->instance) != CHANNEL_RC_OK) + return FALSE; + } freerdp_client_codecs_free(context->codecs); context->codecs = nullptr; diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 6f5d64071..26e9d5004 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -643,7 +643,8 @@ BOOL freerdp_disconnect(freerdp* instance) } } - freerdp_channels_close(instance->context->channels, instance); + if (instance->context->channels) + freerdp_channels_close(instance->context->channels, instance); IFCALL(instance->PostFinalDisconnect, instance); diff --git a/libfreerdp/core/utils.c b/libfreerdp/core/utils.c index 49bb3ca00..a484f4ac5 100644 --- a/libfreerdp/core/utils.c +++ b/libfreerdp/core/utils.c @@ -497,11 +497,17 @@ BOOL utils_reload_channels(rdpContext* context) { WINPR_ASSERT(context); - freerdp_channels_disconnect(context->channels, context->instance); - freerdp_channels_close(context->channels, context->instance); - freerdp_channels_free(context->channels); + if (context->channels) + { + freerdp_channels_disconnect(context->channels, context->instance); + freerdp_channels_close(context->channels, context->instance); + freerdp_channels_free(context->channels); + } + context->channels = freerdp_channels_new(context->instance); - WINPR_ASSERT(context->channels); + if (!context->channels) + return FALSE; + freerdp_channels_register_instance(context->channels, context->instance); BOOL rc = TRUE;