authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-18 15:21:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:20-07:00
log38f2172b0a31ec09a39c3222fd7cde2f2802ae8e
treecf0530603688d3269e168b0231444d36b5e17f7c
parenta3ff4d9b4584b872289f67e94ffa2f0aba9c4257

fix memory leak in addModuleTableToCacheHash


1 files changed, 7 insertions(+), 4 deletions(-)

src/Compilation.zig+7-4
......@@ -1104,6 +1104,7 @@ fn addModuleTableToCacheHash(
11041104 hash_type: union(enum) { path_bytes, files: *Cache.Manifest },
11051105) (error{OutOfMemory} || std.os.GetCwdError)!void {
11061106 var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{};
1107 defer seen_table.deinit(gpa);
11071108 try seen_table.put(gpa, root_mod, {});
11081109
11091110 const SortByName = struct {
......@@ -6172,6 +6173,8 @@ fn buildOutputFromZig(
61726173
61736174 const lf = comp.bin_file.?;
61746175 const unwind_tables = if (lf.cast(link.File.Elf)) |elf| elf.eh_frame_hdr else false;
6176 const strip = comp.compilerRtStrip();
6177 const optimize_mode = comp.compilerRtOptMode();
61756178
61766179 const config = try Config.resolve(.{
61776180 .output_mode = output_mode,
......@@ -6180,8 +6183,8 @@ fn buildOutputFromZig(
61806183 .is_test = false,
61816184 .have_zcu = true,
61826185 .emit_bin = true,
6183 .root_optimize_mode = comp.compilerRtOptMode(),
6184 .root_strip = comp.compilerRtStrip(),
6186 .root_optimize_mode = optimize_mode,
6187 .root_strip = strip,
61856188 .link_libc = comp.config.link_libc,
61866189 .any_unwind_tables = unwind_tables,
61876190 });
......@@ -6195,14 +6198,14 @@ fn buildOutputFromZig(
61956198 .fully_qualified_name = "root",
61966199 .inherited = .{
61976200 .resolved_target = comp.root_mod.resolved_target,
6198 .strip = comp.compilerRtStrip(),
6201 .strip = strip,
61996202 .stack_check = false,
62006203 .stack_protector = 0,
62016204 .red_zone = comp.root_mod.red_zone,
62026205 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
62036206 .unwind_tables = unwind_tables,
62046207 .pic = comp.root_mod.pic,
6205 .optimize_mode = comp.compilerRtOptMode(),
6208 .optimize_mode = optimize_mode,
62066209 .structured_cfg = comp.root_mod.structured_cfg,
62076210 },
62086211 .global = config,