From a5fa416628622916e2a8ec7578a75c8a47787183 Mon Sep 17 00:00:00 2001 From: FiniteSingularity Date: Fri, 29 Aug 2025 11:54:50 -0500 Subject: [PATCH] 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. --- frontend/plugin-manager/PluginManager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/plugin-manager/PluginManager.cpp b/frontend/plugin-manager/PluginManager.cpp index 2fad56d2b..84eab637d 100644 --- a/frontend/plugin-manager/PluginManager.cpp +++ b/frontend/plugin-manager/PluginManager.cpp @@ -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;