From 867c78d8265d6cd487390e23b5aa3a00c7b7aef0 Mon Sep 17 00:00:00 2001 From: InconsolableCellist <23345188+InconsolableCellist@users.noreply.github.com> Date: Sat, 3 Jan 2026 05:10:56 -0700 Subject: [PATCH] Fix infinite loop in find_dir when reaching root directory (#708) The previous loop condition `not copy.empty()` would never terminate at the filesystem root since root paths (e.g., "/" or "C:\") are never empty and their parent_path() returns themselves. --- server/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/main.cpp b/server/main.cpp index 525d045f..a4e60dea 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -146,7 +146,7 @@ static void append_delim(std::string & to, std::string_view what, char delim) // if it can't be found, return the full path static std::filesystem::path find_dir(const std::filesystem::path & d, const std::filesystem::path & needle) { - for (auto copy = d; not copy.empty(); copy = copy.parent_path()) + for (auto copy = d; copy != copy.parent_path(); copy = copy.parent_path()) { if (copy.filename() == needle) return copy;