From 97dfbd9fe8e9716b41efee5d509f927549bc2ca9 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Sun, 26 May 2019 00:31:47 +0200 Subject: [PATCH] Fix memory corruption. --- src/common/KeyMap.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index 6fdc4efaa..91c092599 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -149,17 +149,23 @@ string KeyMap::getDesc(const int mode, const int key, const int mod) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void KeyMap::eraseMode(const int mode) { - for (auto item : myMap) - if (item.first.mode == mode) - erase(item.first); + for (auto i = myMap.begin(); i != myMap.end();) + if (i->first.mode == mode) { + auto _i = i++; + erase(_i->first); + } + else i++; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void KeyMap::eraseEvent(const Event::Type event, const int mode) { - for (auto item : myMap) - if (item.second == event && item.first.mode == mode) - erase(item.first); + for (auto i = myMap.begin(); i != myMap.end();) + if (i->second == event && i->first.mode == mode) { + auto _i = i++; + erase(_i->first); + } + else i++; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -