zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 3ea015db968644c3f4e88fff59b9741b4903d478 (tree)
parent 23fff3442de38877c556f3cda19f3cccef255f7a
Author: Igor Anić <igor.anic@gmail.com>
Date:   Fri,  8 Aug 2025 17:21:45 +0200

Io.Reader fix defaultReadVec

Running tar.pipeToFileSystem compressed_mingw_includes.tar file from #24732
finishes in infinite loop calling defaultReadVec with:
r.seek = 1024
r.end = 1024
r.buffer.len = 1024
first.len = 512
that combination calls vtable.stream with 0 capacity writer and loops
forever.

Comment is to use whichever has larger capacity, and this fix reflects that.

Diffstat:
Mlib/std/Io/Reader.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/std/Io/Reader.zig b/lib/std/Io/Reader.zig @@ -426,7 +426,7 @@ pub fn readVec(r: *Reader, data: [][]u8) Error!usize { /// Writes to `Reader.buffer` or `data`, whichever has larger capacity. pub fn defaultReadVec(r: *Reader, data: [][]u8) Error!usize { const first = data[0]; - if (r.seek == r.end and first.len >= r.buffer.len) { + if (first.len >= r.buffer.len - r.end) { var writer: Writer = .{ .buffer = first, .end = 0,