From a625448d9798aa4e71dcc59606a51f5eea456cdb Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 9 Aug 2017 12:33:16 -0700 Subject: [PATCH] rtmp-services: Initialize mutex/dynamic array The Twitch ingest lookup file did not initialize the dynamic array or mutex before using. --- plugins/rtmp-services/rtmp-services-main.c | 3 +++ plugins/rtmp-services/twitch.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/plugins/rtmp-services/rtmp-services-main.c b/plugins/rtmp-services/rtmp-services-main.c index 3b0c99bca..3897dea0e 100644 --- a/plugins/rtmp-services/rtmp-services-main.c +++ b/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}; diff --git a/plugins/rtmp-services/twitch.c b/plugins/rtmp-services/twitch.c index ea17e3a55..2035824d4 100644 --- a/plugins/rtmp-services/twitch.c +++ b/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); }