Browse Source

libobs: Hold async mutex when calling set_async_texture_size

Calling set_async_texture_size without holding async_mutex is dangerous
as cur_async_frame could be changed / freed by another thread.
Richard Stanway 2 years ago
parent
commit
2468268569
1 changed files with 2 additions and 2 deletions
  1. 2 2
      libobs/obs-source.c

+ 2 - 2
libobs/obs-source.c

@@ -1225,11 +1225,11 @@ static void async_tick(obs_source_t *source)
 		filter_frame(source, &source->prev_async_frame);
 	filter_frame(source, &source->cur_async_frame);
 
-	pthread_mutex_unlock(&source->async_mutex);
-
 	if (source->cur_async_frame)
 		source->async_update_texture =
 			set_async_texture_size(source, source->cur_async_frame);
+
+	pthread_mutex_unlock(&source->async_mutex);
 }
 
 void obs_source_video_tick(obs_source_t *source, float seconds)