diff --git a/gps/utils/LocUnorderedSetMap.h b/gps/utils/LocUnorderedSetMap.h index 7b25ad0..ca99320 100644 --- a/gps/utils/LocUnorderedSetMap.h +++ b/gps/utils/LocUnorderedSetMap.h @@ -141,8 +141,11 @@ public: unordered_set* goneKeys, unordered_set* goneVals) { for (auto key : keys) { auto iter = mMap.find(key); - if (iter != mMap.end() && trimOrRemove(iter, rVals, goneVals) && nullptr != goneKeys) { - goneKeys->insert(iter->first); + if (iter != mMap.end()) { + KEY goneKey = iter->first; + if (trimOrRemove(iter, rVals, goneVals) && nullptr != goneKeys) { + goneKeys->insert(goneKey); + } } } }