Skip to content

Commit

Permalink
libobs: Prevent and log double destroy on sources
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
jp9000 committed Jan 23, 2022
1 parent b9599fe commit 2416dfb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libobs/obs-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2416dfb

Please sign in to comment.