mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-05-11 16:59:43 -04:00
frontend: Fix plugin manager config loading crash
Current code isn't catching a parse error exception if an invalid config file is loaded by the plugin manager. This change wraps the plugin manager config json parse call with a try/catch, and handles invalid config files by creating a new config file, and logs an error that the existing config file is invalid.
This commit is contained in:
committed by
Ryan Foster
parent
747f67e150
commit
a5fa416628
@@ -94,7 +94,15 @@ void PluginManager::loadModules_()
|
||||
auto modulesFile = getConfigFilePath_();
|
||||
if (std::filesystem::exists(modulesFile)) {
|
||||
std::ifstream jsonFile(modulesFile);
|
||||
nlohmann::json data = nlohmann::json::parse(jsonFile);
|
||||
nlohmann::json data;
|
||||
try {
|
||||
data = nlohmann::json::parse(jsonFile);
|
||||
} catch (const nlohmann::json::parse_error &error) {
|
||||
modules_.clear();
|
||||
blog(LOG_ERROR, "Error loading modules config file: %s", error.what());
|
||||
blog(LOG_ERROR, "Generating new config file.");
|
||||
return;
|
||||
}
|
||||
modules_.clear();
|
||||
for (auto it : data) {
|
||||
ModuleInfo obsModule;
|
||||
|
||||
Reference in New Issue
Block a user