From f06f85fd5614f8fa8dfb73d53c5f62ed5ce440fb Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 25 Dec 2017 12:44:46 -0800 Subject: [PATCH] libobs: Prevent access to OBS context during shutdown The "obs" global variable can still be accessed by functions during shutdown. To prevent access to the variable during shutdown, move the pointer to a temporary function variable, and set the "obs" global variable to NULL before shutting down. --- libobs/obs.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/libobs/obs.c b/libobs/obs.c index e8001cc16..44c04a330 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -810,6 +810,7 @@ bool obs_startup(const char *locale, const char *module_config_path, void obs_shutdown(void) { struct obs_module *module; + struct obs_core *core; if (!obs) return; @@ -850,25 +851,27 @@ void obs_shutdown(void) obs->procs = NULL; obs->signals = NULL; - module = obs->first_module; + core = obs; + obs = NULL; + + module = core->first_module; while (module) { struct obs_module *next = module->next; free_module(module); module = next; } - obs->first_module = NULL; + core->first_module = NULL; - for (size_t i = 0; i < obs->module_paths.num; i++) - free_module_path(obs->module_paths.array+i); - da_free(obs->module_paths); + for (size_t i = 0; i < core->module_paths.num; i++) + free_module_path(core->module_paths.array+i); + da_free(core->module_paths); - if (obs->name_store_owned) - profiler_name_store_free(obs->name_store); + if (core->name_store_owned) + profiler_name_store_free(core->name_store); - bfree(obs->module_config_path); - bfree(obs->locale); - bfree(obs); - obs = NULL; + bfree(core->module_config_path); + bfree(core->locale); + bfree(core); #ifdef _WIN32 uninitialize_com();