From e2d91258b7bfb989dc099f516bb31ceb44554529 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sun, 1 Dec 2019 21:26:42 +0000 Subject: PLUGINS: Fix crash when no plugins are available --- base/plugins.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'base') diff --git a/base/plugins.cpp b/base/plugins.cpp index d5733599be..490ca33821 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -641,15 +641,18 @@ const Plugin *EngineManager::findPlugin(const Common::String &engineId) const { } // We failed to find it using the engine ID. Scan the list of plugins - PluginMan.loadFirstPlugin(); - do { - plugin = findLoadedPlugin(engineId); - if (plugin) { - // Update with new plugin file name - PluginMan.updateConfigWithFileName(engineId); - return plugin; - } - } while (PluginMan.loadNextPlugin()); + const PluginList &plugins = getPlugins(); + if (!plugins.empty()) { + PluginMan.loadFirstPlugin(); + do { + plugin = findLoadedPlugin(engineId); + if (plugin) { + // Update with new plugin file name + PluginMan.updateConfigWithFileName(engineId); + return plugin; + } + } while (PluginMan.loadNextPlugin()); + } return 0; } -- cgit v1.2.3