From ab653555f6aa0ec57e1b23a590fb3061929fdc30 Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 5 May 2024 18:00:04 +0200 Subject: Fix plugin with NULL strings causing UB (#695) Instance string members only after checking for null pointers to prevent UB --- primedev/plugins/plugins.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'primedev/plugins') diff --git a/primedev/plugins/plugins.cpp b/primedev/plugins/plugins.cpp index eddaa8ac..ae6fd0cb 100644 --- a/primedev/plugins/plugins.cpp +++ b/primedev/plugins/plugins.cpp @@ -69,10 +69,6 @@ Plugin::Plugin(std::string path) : m_location(path) m_runOnServer = context & PluginContext::DEDICATED; m_runOnClient = context & PluginContext::CLIENT; - m_name = std::string(name); - m_logName = std::string(logName); - m_dependencyName = std::string(dependencyName); - if (!name) { NS::log::PLUGINSYS->error("Could not load name of plugin at '{}'", path); @@ -91,6 +87,10 @@ Plugin::Plugin(std::string path) : m_location(path) return; } + m_name = std::string(name); + m_logName = std::string(logName); + m_dependencyName = std::string(dependencyName); + if (!isValidSquirrelIdentifier(m_dependencyName)) { NS::log::PLUGINSYS->error("Dependency name \"{}\" of plugin {} is not valid", dependencyName, name); -- cgit v1.2.3