From 23f8fd2fee6b42d8995f0ad6bc5b8e91b92c61e2 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 19 Dec 2023 20:21:44 +0100 Subject: [PATCH] [client,sdl] lock connection dialog access might happen from different threads. --- client/SDL/dialogs/sdl_dialogs.cpp | 1 + client/SDL/dialogs/sdl_widget.cpp | 3 ++- client/SDL/sdl_freerdp.cpp | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/SDL/dialogs/sdl_dialogs.cpp b/client/SDL/dialogs/sdl_dialogs.cpp index c4f208a53..e2f98e1a7 100644 --- a/client/SDL/dialogs/sdl_dialogs.cpp +++ b/client/SDL/dialogs/sdl_dialogs.cpp @@ -214,6 +214,7 @@ SSIZE_T sdl_retry_dialog(freerdp* instance, const char* what, size_t current, vo WINPR_ASSERT(what); auto sdl = get_context(instance->context); + std::lock_guard lock(sdl->critical); WINPR_ASSERT(sdl->connection_dialog); sdl->connection_dialog->setTitle("Retry connection to %s", diff --git a/client/SDL/dialogs/sdl_widget.cpp b/client/SDL/dialogs/sdl_widget.cpp index 5d361b668..2d1fc197c 100644 --- a/client/SDL/dialogs/sdl_widget.cpp +++ b/client/SDL/dialogs/sdl_widget.cpp @@ -49,7 +49,8 @@ SdlWidget::SdlWidget(SDL_Renderer* renderer, const SDL_Rect& rect, bool input) else { _font = TTF_OpenFontRW(ops, 1, 64); - widget_log_error(-1, "TTF_OpenFontRW"); + if (!_font) + widget_log_error(-1, "TTF_OpenFontRW"); } } diff --git a/client/SDL/sdl_freerdp.cpp b/client/SDL/sdl_freerdp.cpp index 56d6c8f31..09546c0aa 100644 --- a/client/SDL/sdl_freerdp.cpp +++ b/client/SDL/sdl_freerdp.cpp @@ -598,6 +598,7 @@ static BOOL sdl_pre_connect(freerdp* instance) if (!sdl_wait_for_init(sdl)) return FALSE; + std::lock_guard lock(sdl->critical); sdl->connection_dialog.reset(new SDLConnectionDialog(instance->context)); sdl->connection_dialog->setTitle("Connecting to '%s'", @@ -1104,6 +1105,7 @@ static BOOL sdl_post_connect(freerdp* instance) auto sdl = get_context(context); // Retry was successful, discard dialog + std::lock_guard lock(sdl->critical); if (sdl->connection_dialog) sdl->connection_dialog->hide(); @@ -1176,6 +1178,7 @@ static void sdl_post_final_disconnect(freerdp* instance) auto context = get_context(instance->context); + std::lock_guard lock(context->critical); if (context->connection_dialog) context->connection_dialog->wait(true); context->connection_dialog.reset();