| ... | @@ -276,7 +276,8 @@ pub const ChildProcess = struct { | ... | @@ -276,7 +276,8 @@ pub const ChildProcess = struct { |
| 276 | | 276 | |
| 277 | // Windows Async IO requires an initial call to ReadFile before waiting on the handle | 277 | // Windows Async IO requires an initial call to ReadFile before waiting on the handle |
| 278 | for ([_]u1{ 0, 1 }) |i| { | 278 | for ([_]u1{ 0, 1 }) |i| { |
| 279 | try outs[i].ensureTotalCapacity(bump_amt); | 279 | const new_capacity = std.math.min(outs[i].items.len + bump_amt, max_output_bytes); |
| | 280 | try outs[i].ensureTotalCapacity(new_capacity); |
| 280 | const buf = outs[i].unusedCapacitySlice(); | 281 | const buf = outs[i].unusedCapacitySlice(); |
| 281 | _ = windows.kernel32.ReadFile(handles[i], buf.ptr, math.cast(u32, buf.len) catch maxInt(u32), null, &overlapped[i]); | 282 | _ = windows.kernel32.ReadFile(handles[i], buf.ptr, math.cast(u32, buf.len) catch maxInt(u32), null, &overlapped[i]); |
| 282 | wait_objects[wait_object_count] = handles[i]; | 283 | wait_objects[wait_object_count] = handles[i]; |