From cf28a8af22beda7c06d56fae2cb2e1531dfb76b1 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 15 Apr 2015 16:13:37 -0700 Subject: [PATCH] libobs: Init source mutexes before calling create Fixes a crash that could happen if any of the mutexes are used in the create callback, or before the obs_source_init function is called. I'm not sure how this function order slipped because it seems fairly obvious that these mutexes should be created before the create callback. Had this crash happen to me when creating a WASAPI output source, the create callback of the WASAPI source creates a thread which outputs audio, and that thread managed to call obs_source_output_audio before the obs_source_init function was called, which in turn caused it to try to use a null mutex. --- libobs/obs-source.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 566407d56..1df51e76d 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -189,6 +189,9 @@ obs_source_t *obs_source_create(enum obs_source_type type, const char *id, if (info && info->get_defaults) info->get_defaults(source->context.settings); + if (!obs_source_init(source, info)) + goto fail; + /* allow the source to be created even if creation fails so that the * user's data doesn't become lost */ if (info) @@ -197,9 +200,6 @@ obs_source_t *obs_source_create(enum obs_source_type type, const char *id, if (!source->context.data) blog(LOG_ERROR, "Failed to create source '%s'!", name); - if (!obs_source_init(source, info)) - goto fail; - blog(LOG_INFO, "source '%s' (%s) created", name, id); obs_source_dosignal(source, "source_create", NULL);