authorgravatar for aleksey.kladov@gmail.comAlex Kladov <aleksey.kladov@gmail.com> 2024-09-14 02:42:11+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-24 13:19:06-07:00
logffd071f55821f70fbfc59bab172ae07eaf7cde23
tree47abd9fb28f7b177586445443edc1475624ee1ac
parentc062c532d7b09b4a593328c486f7fcad70886062

fix IB in fifoToOwnedArrayList

memcpy requires non-overlapping arguments. fifo.realign() handles this case correctly and tries to provide an optimized implementation. This probably wasn't hit in practice, as, in a typical usage, fifo's head is not advanced.

1 files changed, 1 insertions(+), 3 deletions(-)

lib/std/process/Child.zig+1-3
...@@ -316,9 +316,7 @@ pub const RunResult = struct {...@@ -316,9 +316,7 @@ pub const RunResult = struct {
316};316};
317317
318fn fifoToOwnedArrayList(fifo: *std.io.PollFifo) std.ArrayList(u8) {318fn fifoToOwnedArrayList(fifo: *std.io.PollFifo) std.ArrayList(u8) {
319 if (fifo.head > 0) {319 if (fifo.head != 0) fifo.realign();
320 @memcpy(fifo.buf[0..fifo.count], fifo.buf[fifo.head..][0..fifo.count]);
321 }
322 const result = std.ArrayList(u8){320 const result = std.ArrayList(u8){
323 .items = fifo.buf[0..fifo.count],321 .items = fifo.buf[0..fifo.count],
324 .capacity = fifo.buf.len,322 .capacity = fifo.buf.len,