Skip to content

Commit

Permalink
libobs: Fix potential filter rendering race condition
Browse files Browse the repository at this point in the history
The filters array should not be accessed without locking the filter
mutex.  This locks the filter mutex, grabs a reference to the first
filter, unlocks the mutex, renders the filter, and then releases the
reference.

Closes obsproject#1215
  • Loading branch information
sorayuki authored and jp9000 committed Apr 20, 2018
1 parent 14b7b47 commit fc26e3c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libobs/obs-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,9 +1720,18 @@ static inline void obs_source_render_async_video(obs_source_t *source)

static inline void obs_source_render_filters(obs_source_t *source)
{
obs_source_t *first_filter;

pthread_mutex_lock(&source->filter_mutex);
first_filter = source->filters.array[0];
obs_source_addref(first_filter);
pthread_mutex_unlock(&source->filter_mutex);

source->rendering_filter = true;
obs_source_video_render(source->filters.array[0]);
obs_source_video_render(first_filter);
source->rendering_filter = false;

obs_source_release(first_filter);
}

void obs_source_default_render(obs_source_t *source)
Expand Down

0 comments on commit fc26e3c

Please sign in to comment.