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.)
This commit is contained in:
jp9000 2022-01-23 11:53:27 -08:00
parent b9599fed2d
commit 2416dfbd5e

View File

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