Skip to content

Commit

Permalink
libobs: Fix crash in obs_sceneitem_remove() when already removed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tt2468 committed Nov 14, 2023
1 parent ea1d022 commit 3e6797c
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions libobs/obs-scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3e6797c

Please sign in to comment.