Skip to content

Commit 3ea015d

Browse files
ianicandrewrk
authored andcommitted
Io.Reader fix defaultReadVec
Running tar.pipeToFileSystem compressed_mingw_includes.tar file from ziglang#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.
1 parent 23fff34 commit 3ea015d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/std/Io/Reader.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ pub fn readVec(r: *Reader, data: [][]u8) Error!usize {
426426
/// Writes to `Reader.buffer` or `data`, whichever has larger capacity.
427427
pub fn defaultReadVec(r: *Reader, data: [][]u8) Error!usize {
428428
const first = data[0];
429-
if (r.seek == r.end and first.len >= r.buffer.len) {
429+
if (first.len >= r.buffer.len - r.end) {
430430
var writer: Writer = .{
431431
.buffer = first,
432432
.end = 0,

0 commit comments

Comments
 (0)