From 00ea8a98973255deb5e44a722bc946976fda629d Mon Sep 17 00:00:00 2001 From: CursedByTheVoid Date: Tue, 23 Jun 2026 22:43:52 -0400 Subject: [PATCH] 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. --- lib/std/zig/LibCInstallation.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/zig/LibCInstallation.zig b/lib/std/zig/LibCInstallation.zig index 770743acf42b3aff4aa4e5232724fe239b4e0007..6fa49a0ce985c9115495a16c862e7d6e1a9062d5 100644 --- a/lib/std/zig/LibCInstallation.zig +++ b/lib/std/zig/LibCInstallation.zig @@ -46,7 +46,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const const field_names = comptime std.meta.fieldNames(LibCInstallation); const FoundKey = struct { found: bool, - allocated: ?[:0]u8, + allocated: ?[]u8, }; 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 if (value.len == 0) { @field(self, field_name) = null; } else { - found_keys[i].allocated = try allocator.dupeSentinel(u8, value, 0); + found_keys[i].allocated = try allocator.dupe(u8, value); @field(self, field_name) = found_keys[i].allocated; } break; -- 2.54.0