Browse Source

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.)
jp9000 3 years ago
parent
commit
2416dfbd5e
1 changed files with 7 additions and 1 deletions
  1. 7 1
      libobs/obs-source.c

+ 7 - 1
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);