0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

obs-ffmpeg: Fix a race condition in create_or_fetch_log_context

Another thread could be manipulating the active_log_contexts array while the current thread is trying to read it, resulting in an uninitialized memory crash as the da_push_back call was not protected by the mutex.
This commit is contained in:
Richard Stanway 2015-10-12 22:41:18 +02:00
parent 7630946874
commit 55dd8f8726

View File

@ -36,7 +36,6 @@ static struct log_context *create_or_fetch_log_context(void *context)
new_log_context = cached_log_contexts.array[cnt - 1];
da_pop_back(cached_log_contexts);
}
pthread_mutex_unlock(&log_contexts_mutex);
if (!new_log_context)
new_log_context = bzalloc(sizeof(struct log_context));
@ -47,6 +46,8 @@ static struct log_context *create_or_fetch_log_context(void *context)
da_push_back(active_log_contexts, &new_log_context);
pthread_mutex_unlock(&log_contexts_mutex);
return new_log_context;
}