diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2025-12-20 02:01:50 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-12-26 19:58:56 -0800 |
| commit | 58f0c8cfed1c8dd2fb29cf4a1807e6e0d239c006 (patch) | |
| tree | 058bcd0da12b540025bec63594ecbcab84b21780 | |
| parent | eb29737d5d77b195b1e030e6bcb99ed0e30ede33 (diff) | |
| download | zig-58f0c8cfed1c8dd2fb29cf4a1807e6e0d239c006.tar.gz zig-58f0c8cfed1c8dd2fb29cf4a1807e6e0d239c006.zip | |
Fix logic for detecting zero buffer capacity in fileReadStreamingWindows/fileReadPositionalWindows
| -rw-r--r-- | lib/std/Io/Threaded.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index d9bc6e0d1a..3241c45d5c 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); |
