commit ffd071f55821f70fbfc59bab172ae07eaf7cde23 (tree)
parent c062c532d7b09b4a593328c486f7fcad70886062
Author: Alex Kladov <aleksey.kladov@gmail.com>
Date: Sat, 14 Sep 2024 02:42:11 +0100
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.
Diffstat:
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/std/process/Child.zig b/lib/std/process/Child.zig
@@ -316,9 +316,7 @@ pub const RunResult = struct {
};
fn fifoToOwnedArrayList(fifo: *std.io.PollFifo) std.ArrayList(u8) {
- if (fifo.head > 0) {
- @memcpy(fifo.buf[0..fifo.count], fifo.buf[fifo.head..][0..fifo.count]);
- }
+ if (fifo.head != 0) fifo.realign();
const result = std.ArrayList(u8){
.items = fifo.buf[0..fifo.count],
.capacity = fifo.buf.len,