aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorRyan Liptak <squeek502@hotmail.com>2021-09-17 12:43:47 -0700
committerIsaac Freund <ifreund@ifreund.xyz>2021-09-19 13:52:56 +0200
commit224d4de747d02f4b7add6a7e18512467b6d33569 (patch)
tree8e16693234c535d50edbc7217ea6a84b97b501b3 /lib/std
parent59f5053beda7087a73983835e9f7e00dc3143d59 (diff)
downloadzig-224d4de747d02f4b7add6a7e18512467b6d33569.tar.gz
zig-224d4de747d02f4b7add6a7e18512467b6d33569.zip
Improve ensureTotalCapacity call in ChildProcess.collectOutputWindows
Take current len and max_output_bytes into account instead of unconditionally using bump_amt
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/child_process.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig
index 11b95a6e36..b6f4f4c516 100644
--- a/lib/std/child_process.zig
+++ b/lib/std/child_process.zig
@@ -276,7 +276,8 @@ pub const ChildProcess = struct {
// Windows Async IO requires an initial call to ReadFile before waiting on the handle
for ([_]u1{ 0, 1 }) |i| {
- try outs[i].ensureTotalCapacity(bump_amt);
+ const new_capacity = std.math.min(outs[i].items.len + bump_amt, max_output_bytes);
+ try outs[i].ensureTotalCapacity(new_capacity);
const buf = outs[i].unusedCapacitySlice();
_ = windows.kernel32.ReadFile(handles[i], buf.ptr, math.cast(u32, buf.len) catch maxInt(u32), null, &overlapped[i]);
wait_objects[wait_object_count] = handles[i];