srctree

Isaac Freund parent 7c2cc45a b196dd1d
std.system: fix slice bounds in preadMin()

If a partial read occurs past the halfway point, buf.len - i will beless than i, which is illegal. The end bound is also entirely unecessaryin this case, so just remove it.

inlinesplit
lib/std/zig/system.zig added: 2, removed: 2, total 0
@@ -922,7 +922,7 @@ pub const NativeTargetInfo = struct {
fn preadMin(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usize {
var i: usize = 0;
while (i < min_read_len) {
const len = file.pread(buf[i .. buf.len - i], offset + i) catch |err| switch (err) {
const len = file.pread(buf[i..], offset + i) catch |err| switch (err) {
error.OperationAborted => unreachable, // Windows-only
error.WouldBlock => unreachable, // Did not request blocking mode
error.NotOpenForReading => unreachable,