From d2d35d055379c5e7be868cc1bc2a857bf3734d4d Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 3 Nov 2025 12:31:03 -0800 Subject: [PATCH] pidof: Fixes another unexpected throw location Exit early if the directory goes away before the iterator is created. --- Source/Tools/pidof/pidof.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/Tools/pidof/pidof.cpp b/Source/Tools/pidof/pidof.cpp index 27f085e71..2cd9998c6 100644 --- a/Source/Tools/pidof/pidof.cpp +++ b/Source/Tools/pidof/pidof.cpp @@ -87,13 +87,20 @@ bool FindWineFEXApplication(int64_t PID, std::string_view exe, const std::vector } // Wine was found, scan the mapped files to see if anything mapped "libarm64ecfex.dll" or "libwow64fex.dll" - for (const auto& Entry : std::filesystem::directory_iterator(fmt::format("/proc/{}/map_files", PID))) { + + std::error_code ec {}; + auto dir_iter = std::filesystem::directory_iterator(fmt::format("/proc/{}/map_files", PID), ec); + // If error reading symlink then skip. + if (ec) { + return false; + } + + for (const auto& Entry : dir_iter) { // If not a symlink then skip. if (!Entry.is_symlink()) { continue; } - std::error_code ec {}; const auto symlink_path = std::filesystem::read_symlink(Entry.path(), ec); // If error reading symlink then skip. if (ec) {