libobs: Fix crash in obs_sceneitem_remove() when already removed

An already-removed item has a NULL `item->parent`, meaning that calling
`full_lock(scene)` results in undefined behavior. This makes the method
return earlier if the specified item is removed instead of attempting
to lock the scene.

No thread safety is changed, because it wasn't thread-safe to begin
with.
This commit is contained in:
tt2468 2023-11-13 22:37:42 -08:00
parent ea1d022c20
commit 3e6797ca5b

View file

@ -2254,19 +2254,13 @@ void obs_sceneitem_remove(obs_sceneitem_t *item)
{
obs_scene_t *scene;
if (!item)
if (!item || item->removed)
return;
scene = item->parent;
full_lock(scene);
if (item->removed) {
if (scene)
full_unlock(scene);
return;
}
item->removed = true;
assert(scene != NULL);