From 595e88ae7d3cca6b05b1dfb4c3cd3ed74a1a7861 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Fri, 13 Jun 2025 09:49:48 +0000 Subject: [PATCH] Windows: make read_dir stop iterating on error --- library/std/src/sys/fs/windows.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs index a95709b489143..9b674a251652b 100644 --- a/library/std/src/sys/fs/windows.rs +++ b/library/std/src/sys/fs/windows.rs @@ -132,6 +132,7 @@ impl Iterator for ReadDir { let mut wfd = mem::zeroed(); loop { if c::FindNextFileW(handle.0, &mut wfd) == 0 { + self.handle = None; match api::get_last_error() { WinError::NO_MORE_FILES => return None, WinError { code } => {