From 2416dfbd5e5a77d126bd686d488fa8a3bf77b535 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 23 Jan 2022 11:53:27 -0800 Subject: [PATCH] libobs: Prevent and log double destroy on sources This prevents double destroys from happening on sources and causing crashes. If someone's doing a double destroy it'll probably crash anyway but at least we'll know what happened if it does. (Jim note: I suspect third party plugins are calling addref on sources when they shouldn't be. Either that or we're missing something ourselves, but I suppose we'll see.) --- libobs/obs-source.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 98c03bde6..2a6a1d2dd 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -619,7 +619,13 @@ void obs_source_destroy(struct obs_source *source) if (!obs_source_valid(source, "obs_source_destroy")) return; - os_atomic_set_long(&source->destroying, true); + if (os_atomic_set_long(&source->destroying, true) == true) { + blog(LOG_ERROR, "Double destroy just occurred. " + "Something called addref on a source " + "after it was already fully released, " + "I guess."); + return; + } if (is_audio_source(source)) { pthread_mutex_lock(&source->audio_cb_mutex);