authorgravatar for tristancrawford@proton.meCursedByTheVoid <tristancrawford@proton.me> 2026-06-23 22:43:52-04:00
committergravatar for tristancrawford@proton.meCursedByTheVoid <tristancrawford@proton.me> 2026-06-23 22:56:21-04:00
log00ea8a98973255deb5e44a722bc946976fda629d
tree5fd09d84491696bab5755f09aaaa7e9bc9c675d4
parent5dc2651cdd6ec35c99a3bc6e21787064758c0721

std.zig.LibCInstallation: fix parse panic

Swaps `dupeSentinel` for `dupe` in the `parse` function. Aside from being inconsistent with the other `findNative` functions in the file, `dupeSentinel` also causes `deinit` to panic because it attempts to free fewer bytes than were allocated.

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/zig/LibCInstallation.zig+2-2
...@@ -46,7 +46,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const...@@ -46,7 +46,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
46 const field_names = comptime std.meta.fieldNames(LibCInstallation);46 const field_names = comptime std.meta.fieldNames(LibCInstallation);
47 const FoundKey = struct {47 const FoundKey = struct {
48 found: bool,48 found: bool,
49 allocated: ?[:0]u8,49 allocated: ?[]u8,
50 };50 };
5151
52 var found_keys: [field_names.len]FoundKey = @splat(.{ .found = false, .allocated = null });52 var found_keys: [field_names.len]FoundKey = @splat(.{ .found = false, .allocated = null });
...@@ -72,7 +72,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const...@@ -72,7 +72,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
72 if (value.len == 0) {72 if (value.len == 0) {
73 @field(self, field_name) = null;73 @field(self, field_name) = null;
74 } else {74 } else {
75 found_keys[i].allocated = try allocator.dupeSentinel(u8, value, 0);75 found_keys[i].allocated = try allocator.dupe(u8, value);
76 @field(self, field_name) = found_keys[i].allocated;76 @field(self, field_name) = found_keys[i].allocated;
77 }77 }
78 break;78 break;