Fix UpdateCrashedWriterPackageInfo
[platform/core/appfw/pkgmgr-info.git] / 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);