Pārlūkot izejas kodu

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.

(cherry picked from commit 3e6797ca5bfe445381d721e407163b70b8de6d1e)
tt2468 1 gadu atpakaļ
vecāks
revīzija
dcda5b1022
1 mainītis faili ar 1 papildinājumiem un 7 dzēšanām
  1. 1 7
      libobs/obs-scene.c

+ 1 - 7
libobs/obs-scene.c

@@ -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);