sm6150-common: gps: Avoid access of deprecated LocUnorderedSetMap entry

When there is no client listens to some DataItemId, we will remove
the map entry. Can't access the deleted entry's iterator anymore.

Change-Id: Id64aadebf7362667fbcf0fd5191f888ed9241727
CRs-Fixed: 3886536
(cherry picked from commit 0049d459cc1772f328e29a4c6b6d129af132e7b8)
Signed-off-by: therealmharc <therealmharc@gmail.com>
This commit is contained in:
yingjiew
2024-08-01 17:01:05 +08:00
committed by therealmharc
parent d417b91b3f
commit db725d07f5

View File

@@ -141,8 +141,11 @@ public:
unordered_set<KEY>* goneKeys, unordered_set<VAL>* goneVals) { unordered_set<KEY>* goneKeys, unordered_set<VAL>* goneVals) {
for (auto key : keys) { for (auto key : keys) {
auto iter = mMap.find(key); auto iter = mMap.find(key);
if (iter != mMap.end() && trimOrRemove(iter, rVals, goneVals) && nullptr != goneKeys) { if (iter != mMap.end()) {
goneKeys->insert(iter->first); KEY goneKey = iter->first;
if (trimOrRemove(iter, rVals, goneVals) && nullptr != goneKeys) {
goneKeys->insert(goneKey);
}
} }
} }
} }