@samitouri / QOSAMI-WSL / commits / c3d369df

Fix service crash when collecting a linux crash dump when maxCrashDumpCount is set to 0 (#13755)

* Fix service crash when collecting a linux crash dump when maxCrashDumpCount is set to 0 * Move the check inside the function

Blue committed Nov 21, 2025 at 16:16 UTC c3d369df90f7a7b6df83f50889dc1c8854564dfa
1 file changed +6 -1
src/windows/common/wslutil.cpp
+6 -1
@@ -594,6 +594,11 @@ std::wstring wsl::windows::common::wslutil::DownloadFile(std::wstring_view Url,
594
595 void wsl::windows::common::wslutil::EnforceFileLimit(LPCWSTR Path, size_t Limit, const std::function<bool(const std::filesystem::directory_entry&)>& pred)
596 {
597 + if (Limit <= 0)
598 + {
599 + return;
600 + }
601 +
602 std::map<std::filesystem::file_time_type, std::filesystem::path> files;
603 for (auto const& e : std::filesystem::directory_iterator{Path})
604 {
@@ -603,7 +608,7 @@ void wsl::windows::common::wslutil::EnforceFileLimit(LPCWSTR Path, size_t Limit,
608 }
609 }
610
606 - if (Limit < 0 || files.size() < Limit)
611 + if (files.size() < Limit)
612 {
613 return;
614 }