diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index d9bc6e0d1ad75657f47d5748b5a6b9649c7ab58a..3241c45d5ca804ed59301c4e86a09cd2ead11f5e 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -6780,8 +6780,8 @@ fn fileReadStreamingWindows(userdata: ?*anyopaque, file: File, data: []const []u const DWORD = windows.DWORD; var index: usize = 0; - while (data[index].len == 0) index += 1; - if (index == 0) return 0; + while (index < data.len and data[index].len == 0) index += 1; + if (index == data.len) return 0; const buffer = data[index]; const want_read_count: DWORD = @min(std.math.maxInt(DWORD), buffer.len); @@ -6912,8 +6912,8 @@ fn fileReadPositionalWindows(userdata: ?*anyopaque, file: File, data: []const [] const DWORD = windows.DWORD; var index: usize = 0; - while (data[index].len == 0) index += 1; - if (index == 0) return 0; + while (index < data.len and data[index].len == 0) index += 1; + if (index == data.len) return 0; const buffer = data[index]; const want_read_count: DWORD = @min(std.math.maxInt(DWORD), buffer.len);