mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
Compilation: don't give len=0 bufs to pwritev
The OS returns EFAULT for undefined pointers, even when len=0.
This commit is contained in:
parent
cac7e5afc7
commit
29512f0edd
@ -2827,6 +2827,9 @@ pub fn saveState(comp: *Compilation) !void {
|
||||
}
|
||||
|
||||
fn addBuf(bufs_list: []std.posix.iovec_const, bufs_len: *usize, buf: []const u8) void {
|
||||
// Even when len=0, the undefined pointer might cause EFAULT.
|
||||
if (buf.len == 0) return;
|
||||
|
||||
const i = bufs_len.*;
|
||||
bufs_len.* = i + 1;
|
||||
bufs_list[i] = .{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user