Skip to content

Commit

Permalink
Merge pull request #22243 from mlugg/better-imc
Browse files Browse the repository at this point in the history
Sema: disallow unsafe in-memory coercions
  • Loading branch information
mlugg authored Dec 16, 2024
2 parents d12c0bf + 512cb22 commit 32354d1
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 144 deletions.
6 changes: 3 additions & 3 deletions lib/compiler/build_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1364,20 +1364,20 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
);
}

fn nextArg(args: [][:0]const u8, idx: *usize) ?[:0]const u8 {
fn nextArg(args: []const [:0]const u8, idx: *usize) ?[:0]const u8 {
if (idx.* >= args.len) return null;
defer idx.* += 1;
return args[idx.*];
}

fn nextArgOrFatal(args: [][:0]const u8, idx: *usize) [:0]const u8 {
fn nextArgOrFatal(args: []const [:0]const u8, idx: *usize) [:0]const u8 {
return nextArg(args, idx) orelse {
std.debug.print("expected argument after '{s}'\n access the help menu with 'zig build -h'\n", .{args[idx.* - 1]});
process.exit(1);
};
}

fn argsRest(args: [][:0]const u8, idx: usize) ?[][:0]const u8 {
fn argsRest(args: []const [:0]const u8, idx: usize) ?[]const [:0]const u8 {
if (idx >= args.len) return null;
return args[idx..];
}
Expand Down
8 changes: 4 additions & 4 deletions lib/std/c/darwin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1232,16 +1232,16 @@ pub extern "c" fn posix_spawn(
path: [*:0]const u8,
actions: ?*const posix_spawn_file_actions_t,
attr: ?*const posix_spawnattr_t,
argv: [*:null]?[*:0]const u8,
env: [*:null]?[*:0]const u8,
argv: [*:null]const ?[*:0]const u8,
env: [*:null]const ?[*:0]const u8,
) c_int;
pub extern "c" fn posix_spawnp(
pid: *pid_t,
path: [*:0]const u8,
actions: ?*const posix_spawn_file_actions_t,
attr: ?*const posix_spawnattr_t,
argv: [*:null]?[*:0]const u8,
env: [*:null]?[*:0]const u8,
argv: [*:null]const ?[*:0]const u8,
env: [*:null]const ?[*:0]const u8,
) c_int;

pub const E = enum(u16) {
Expand Down
8 changes: 4 additions & 4 deletions src/DarwinPosixSpawn.zig
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ pub fn spawn(
path: []const u8,
actions: ?Actions,
attr: ?Attr,
argv: [*:null]?[*:0]const u8,
envp: [*:null]?[*:0]const u8,
argv: [*:null]const ?[*:0]const u8,
envp: [*:null]const ?[*:0]const u8,
) Error!std.c.pid_t {
const posix_path = try std.posix.toPosixPath(path);
return spawnZ(&posix_path, actions, attr, argv, envp);
Expand All @@ -172,8 +172,8 @@ pub fn spawnZ(
path: [*:0]const u8,
actions: ?Actions,
attr: ?Attr,
argv: [*:null]?[*:0]const u8,
envp: [*:null]?[*:0]const u8,
argv: [*:null]const ?[*:0]const u8,
envp: [*:null]const ?[*:0]const u8,
) Error!std.c.pid_t {
var pid: std.c.pid_t = undefined;
switch (errno(std.c.posix_spawn(
Expand Down
Loading

0 comments on commit 32354d1

Please sign in to comment.