From 2fa208adfbe6861bc480eecbd6e0e569d6a5010a Mon Sep 17 00:00:00 2001 From: Palana Date: Wed, 29 Jan 2014 22:52:05 +0100 Subject: [PATCH] Check if scene item is actually alive when calling obs_sceneitem_destroy Prevents a double free in case the scene item was previously removed --- libobs/obs-scene.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libobs/obs-scene.c b/libobs/obs-scene.c index 5214d2894..630df389d 100644 --- a/libobs/obs-scene.c +++ b/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, ¶ms); calldata_free(¶ms); -- GitLab