From 8d82263513805ba30a3d8ee45ed32f88a6610e1d Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Mon, 14 Aug 2023 18:09:05 +0200 Subject: [PATCH] UI: Fix possible race condition in DrawSpacingHelpers The use of GetCurrentSceneItem can lead to a race condition between the graphics thread (where this function will be run) and the main UI thread, as both access the scene list model and iterate through its members which can change during iteration (as there is no lock around its access). --- UI/window-basic-preview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index d3c9e4e55..48317ee13 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -2461,10 +2461,10 @@ void OBSBasicPreview::DrawSpacingHelpers() obs_scene_enum_items(main->GetCurrentScene(), FindSelected, &data); - if (data.sceneItems.size() > 1) + if (data.sceneItems.size() != 1) return; - OBSSceneItem item = main->GetCurrentSceneItem(); + OBSSceneItem item = data.sceneItems[0]; if (!item) return;