Skip to content

Commit 41a4908

Browse files
authored
Merge pull request #17419 from ziglang/unsound-native-target-info
std: fix memory bug in getExternalExecutor
2 parents 2d0ddce + 91ef6d1 commit 41a4908

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

lib/std/Build/Step/Run.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ fn runCommand(
679679
}
680680

681681
const need_cross_glibc = exe.target.isGnuLibC() and exe.is_linking_libc;
682-
switch (b.host.getExternalExecutor(exe.target_info, .{
682+
switch (b.host.getExternalExecutor(&exe.target_info, .{
683683
.qemu_fixes_dl = need_cross_glibc and b.glibc_runtimes_dir != null,
684684
.link_libc = exe.is_linking_libc,
685685
})) {

lib/std/zig/system/NativeTargetInfo.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ pub const GetExternalExecutorOptions = struct {
10021002
/// of the other target.
10031003
pub fn getExternalExecutor(
10041004
host: NativeTargetInfo,
1005-
candidate: NativeTargetInfo,
1005+
candidate: *const NativeTargetInfo,
10061006
options: GetExternalExecutorOptions,
10071007
) Executor {
10081008
const os_match = host.target.os.tag == candidate.target.os.tag;

src/main.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3667,7 +3667,7 @@ fn buildOutputType(
36673667
test_exec_args.items,
36683668
self_exe_path.?,
36693669
arg_mode,
3670-
target_info,
3670+
&target_info,
36713671
&comp_destroyed,
36723672
all_args,
36733673
runtime_args_start,
@@ -3995,7 +3995,7 @@ fn runOrTest(
39953995
test_exec_args: []const ?[]const u8,
39963996
self_exe_path: []const u8,
39973997
arg_mode: ArgMode,
3998-
target_info: std.zig.system.NativeTargetInfo,
3998+
target_info: *const std.zig.system.NativeTargetInfo,
39993999
comp_destroyed: *bool,
40004000
all_args: []const []const u8,
40014001
runtime_args_start: ?usize,
@@ -6256,7 +6256,7 @@ fn parseIntSuffix(arg: []const u8, prefix_len: usize) u64 {
62566256
fn warnAboutForeignBinaries(
62576257
arena: Allocator,
62586258
arg_mode: ArgMode,
6259-
target_info: std.zig.system.NativeTargetInfo,
6259+
target_info: *const std.zig.system.NativeTargetInfo,
62606260
link_libc: bool,
62616261
) !void {
62626262
const host_cross_target: std.zig.CrossTarget = .{};

test/src/Cases.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ pub fn lowerToBuildSteps(
590590
const run = if (case.target.ofmt == .c) run_step: {
591591
const target_info = std.zig.system.NativeTargetInfo.detect(case.target) catch |err|
592592
std.debug.panic("unable to detect notive host: {s}\n", .{@errorName(err)});
593-
if (host.getExternalExecutor(target_info, .{ .link_libc = true }) != .native) {
593+
if (host.getExternalExecutor(&target_info, .{ .link_libc = true }) != .native) {
594594
// We wouldn't be able to run the compiled C code.
595595
break :no_exec;
596596
}

tools/docgen.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ fn genHtml(
15711571
const target_info = try std.zig.system.NativeTargetInfo.detect(
15721572
cross_target,
15731573
);
1574-
switch (host.getExternalExecutor(target_info, .{
1574+
switch (host.getExternalExecutor(&target_info, .{
15751575
.link_libc = code.link_libc,
15761576
})) {
15771577
.native => {},

0 commit comments

Comments
 (0)