From b5e60ae1b0568d6c9e47134dd2bda70906a2dad9 Mon Sep 17 00:00:00 2001 From: lat9nq Date: Mon, 7 Mar 2022 03:37:54 -0500 Subject: video_core: Cancel Scoped's exit call on GPU failure When CreateRenderer fails, the GraphicsContext that was std::move'd into it is destroyed before the Scoped that was created to manage its currency. In that case, the GraphicsContext::Scoped will still call its destructor at the ending of the function. And because the context is destroyed, the Scoped will cause a crash as it attempts to call a destroyed object's DoneCurrent function. Since we know when the call would be invalid, call the Scoped's Cancel method. This prevents it from calling a method on a destroyed object. --- src/video_core/video_core.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 329bf4def..2f2594585 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -50,6 +50,7 @@ std::unique_ptr CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor gpu->BindRenderer(std::move(renderer)); return gpu; } catch (const std::runtime_error& exception) { + scope.Cancel(); LOG_ERROR(HW_GPU, "Failed to initialize GPU: {}", exception.what()); return nullptr; } -- cgit v1.2.3