Skip to content

Commit c3d369d

Browse files
authored
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
1 parent 1b7e27e commit c3d369d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/windows/common/wslutil.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,11 @@ std::wstring wsl::windows::common::wslutil::DownloadFile(std::wstring_view Url,
594594

595595
void wsl::windows::common::wslutil::EnforceFileLimit(LPCWSTR Path, size_t Limit, const std::function<bool(const std::filesystem::directory_entry&)>& pred)
596596
{
597+
if (Limit <= 0)
598+
{
599+
return;
600+
}
601+
597602
std::map<std::filesystem::file_time_type, std::filesystem::path> files;
598603
for (auto const& e : std::filesystem::directory_iterator{Path})
599604
{
@@ -603,7 +608,7 @@ void wsl::windows::common::wslutil::EnforceFileLimit(LPCWSTR Path, size_t Limit,
603608
}
604609
}
605610

606-
if (Limit < 0 || files.size() < Limit)
611+
if (files.size() < Limit)
607612
{
608613
return;
609614
}

0 commit comments

Comments
 (0)