From d71dccd68f1aac39ad0726d72a95293b24f0e553 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 3 May 2024 08:51:02 +0900 Subject: [PATCH] Fix UpdateCrashedWriterPackageInfo Fix the infinite loop problem Change-Id: If199cfc0500f1ce3f5ea7a6c0d59b0e242a85f53 Signed-off-by: Ilho Kim --- src/server/database/db_handle_provider.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/server/database/db_handle_provider.cc b/src/server/database/db_handle_provider.cc index 83a64fe..53c8e39 100644 --- a/src/server/database/db_handle_provider.cc +++ b/src/server/database/db_handle_provider.cc @@ -508,14 +508,12 @@ void DBHandleProvider::UpdateCrashedWriterPackageInfo( uid_t uid, const std::string& locale, const std::unordered_set& pids) { std::vector 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); -- 2.7.4