瀏覽代碼

rtmp-services: Initialize mutex/dynamic array

The Twitch ingest lookup file did not initialize the dynamic array or
mutex before using.
jp9000 8 年之前
父節點
當前提交
a625448d97
共有 2 個文件被更改,包括 10 次插入0 次删除
  1. 3 0
      plugins/rtmp-services/rtmp-services-main.c
  2. 7 0
      plugins/rtmp-services/twitch.c

+ 3 - 0
plugins/rtmp-services/rtmp-services-main.c

@@ -40,11 +40,14 @@ static bool confirm_service_file(void *param, struct file_download_data *file)
 	return true;
 }
 
+extern void init_twitch_data(void);
 extern void load_twitch_data(const char *module_str);
 extern void unload_twitch_data(void);
 
 bool obs_module_load(void)
 {
+	init_twitch_data();
+
 	char *local_dir = obs_module_file("");
 	char *cache_dir = obs_module_config_path("");
 	struct dstr module_name = {0};

+ 7 - 0
plugins/rtmp-services/twitch.c

@@ -135,6 +135,12 @@ struct twitch_ingest twitch_ingest(size_t idx)
 	return ingest;
 }
 
+void init_twitch_data(void)
+{
+	da_init(cur_ingests);
+	pthread_mutex_init(&mutex, NULL);
+}
+
 void load_twitch_data(const char *module_str)
 {
 	char *twitch_cache = obs_module_config_path("twitch_ingests.json");
@@ -162,4 +168,5 @@ void unload_twitch_data(void)
 {
 	update_info_destroy(twitch_update_info);
 	free_ingests();
+	pthread_mutex_destroy(&mutex);
 }