소스 검색

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.
jp9000 10 년 전
부모
커밋
cf28a8af22
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      libobs/obs-source.c

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