Browse Source

Check if scene item is actually alive when calling obs_sceneitem_destroy

Prevents a double free in case the scene item was previously removed
Palana 11 years ago
parent
commit
2fa208adfb
1 changed files with 10 additions and 1 deletions
  1. 10 1
      libobs/obs-scene.c

+ 10 - 1
libobs/obs-scene.c

@@ -302,7 +302,16 @@ int obs_sceneitem_destroy(obs_scene_t scene, obs_sceneitem_t item)
 
 	pthread_mutex_lock(&scene->mutex);
 
-	if (item) {
+	bool found = false;
+	obs_sceneitem_t i = scene->first_item;
+	while (i) {
+		if (i == item) {
+			found = true;
+			break;
+		}
+	}
+
+	if (found) {
 		struct calldata params = {0};
 		signal_item_destroy(item, &params);
 		calldata_free(&params);