Fix UpdateCrashedWriterPackageInfo 17/310617/1
authorIlho Kim <ilho159.kim@samsung.com>
Thu, 2 May 2024 23:51:02 +0000 (08:51 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Thu, 2 May 2024 23:51:02 +0000 (08:51 +0900)
Fix the infinite loop problem

Change-Id: If199cfc0500f1ce3f5ea7a6c0d59b0e242a85f53
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/server/database/db_handle_provider.cc

index 83a64fe..53c8e39 100644 (file)
@@ -508,14 +508,12 @@ void DBHandleProvider::UpdateCrashedWriterPackageInfo(
     uid_t uid, const std::string& locale,
     const std::unordered_set<pid_t>& pids) {
   std::vector<std::string> pkgids;
-  for (auto it = pending_pkg_.begin(); it != pending_pkg_.end();) {
-    pid_t pid = it->second;
-    if (pids.find(pid) == pids.end()) {
-      it++;
+  for (const auto& [pkgid, pid] : pending_pkg_) {
+    if (pids.find(pid) == pids.end())
       continue;
-    }
 
-    pkgids.emplace_back(it->first);
+    EraseWriterPID(pid);
+    pkgids.emplace_back(pkgid);
   }
 
   UpdatePendingPackageInfo(db, uid, locale, pkgids);