From 331d3c7a1157bdeb9ee9a7c7482801ea21e3f7dd Mon Sep 17 00:00:00 2001 From: gereon Date: Thu, 13 Dec 2012 22:34:36 +0100 Subject: [PATCH] fixing invalid read iterators just don't survive an erase... --- src/utility/settings.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utility/settings.cpp b/src/utility/settings.cpp index 94aba1f15..525f9a02f 100644 --- a/src/utility/settings.cpp +++ b/src/utility/settings.cpp @@ -74,6 +74,8 @@ Settings::Settings(const int argc, const char* argv[], const char* filename) // Perform first parse run this->firstRun(argc, argv, filename); + // Buffer for items to be deleted + std::list< std::pair< std::string, std::string > > deleteQueue; // Check module triggers for (auto it : Settings::modules) { @@ -83,11 +85,12 @@ Settings::Settings(const int argc, const char* argv[], const char* filename) if (this->vm[trigger.first].as().compare(trigger.second) == 0) { Settings::desc->add(*it.second); - Settings::modules.erase(trigger); + deleteQueue.push_back(trigger); } } - } + for (auto it : deleteQueue) Settings::modules.erase(it); + // Stop if help is set if (this->vm.count("help") > 0)