Filter DataItems with suitable way.

We should carefully modify unordered_set when traversing it.
Update the iterator with the return value of erase function.

(cherry picked from commit 7e67a69c3afb01995be46ed45d3f328f0154f81c)
Bug: 117118677
CRs-Fixed: 2288358
Change-Id: Icd4664bf479f1d37b61dae0f9d793777d88a00d0
diff --git a/sdm845/core/SystemStatusOsObserver.cpp b/sdm845/core/SystemStatusOsObserver.cpp
index 0f6d228..8127e86 100644
--- a/sdm845/core/SystemStatusOsObserver.cpp
+++ b/sdm845/core/SystemStatusOsObserver.cpp
@@ -328,9 +328,12 @@
             for (auto client : clientSet) {
                 unordered_set<DataItemId> dataItemIdsForThisClient(
                         mParent->mClientToDataItems.getValSet(client));
-                for (auto id : dataItemIdsForThisClient) {
-                    if (dataItemIdsToBeSent.find(id) == dataItemIdsToBeSent.end()) {
-                        dataItemIdsForThisClient.erase(id);
+                for (auto itr = dataItemIdsForThisClient.begin();
+                        itr != dataItemIdsForThisClient.end(); ) {
+                    if (dataItemIdsToBeSent.find(*itr) == dataItemIdsToBeSent.end()) {
+                        itr = dataItemIdsForThisClient.erase(itr);
+                    } else {
+                        itr++;
                     }
                 }