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 --- backends/plugins/elf/elf-provider.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'backends/plugins') diff --git a/backends/plugins/elf/elf-provider.cpp b/backends/plugins/elf/elf-provider.cpp index 28536eee94..6d461c79df 100644 --- a/backends/plugins/elf/elf-provider.cpp +++ b/backends/plugins/elf/elf-provider.cpp @@ -181,15 +181,17 @@ PluginList ELFPluginProvider::getPlugins() { PluginList pl = FilePluginProvider::getPlugins(); #if defined(UNCACHED_PLUGINS) && !defined(ELF_NO_MEM_MANAGER) - // This static downcast is safe because all of the plugins must - // be ELF plugins - for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) { - (static_cast(*p))->trackSize(); - } + if (!pl.empty()) { + // This static downcast is safe because all of the plugins must + // be ELF plugins + for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) { + (static_cast(*p))->trackSize(); + } - // The Memory Manager should now allocate space based on the information - // it collected - ELFMemMan.allocateHeap(); + // The Memory Manager should now allocate space based on the information + // it collected + ELFMemMan.allocateHeap(); + } #endif return pl; -- cgit v1.2.3