macho+zld: properly deinit code signature object

This commit is contained in:
Jakub Konka 2022-12-23 14:35:45 +01:00
parent 2cb6db2219
commit 22b39f034b
2 changed files with 4 additions and 2 deletions

View File

@ -574,11 +574,12 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
var codesig = CodeSignature.init(self.page_size);
codesig.code_directory.ident = self.base.options.emit.?.sub_path;
if (self.base.options.entitlements) |path| {
try codesig.addEntitlements(arena, path);
try codesig.addEntitlements(self.base.allocator, path);
}
try self.writeCodeSignaturePadding(&codesig);
break :blk codesig;
} else null;
defer if (codesig) |*csig| csig.deinit(self.base.allocator);
// Write load commands
var lc_buffer = std.ArrayList(u8).init(arena);

View File

@ -4115,11 +4115,12 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr
var codesig = CodeSignature.init(page_size);
codesig.code_directory.ident = fs.path.basename(full_out_path);
if (options.entitlements) |path| {
try codesig.addEntitlements(arena, path);
try codesig.addEntitlements(zld.gpa, path);
}
try zld.writeCodeSignaturePadding(&codesig);
break :blk codesig;
} else null;
defer if (codesig) |*csig| csig.deinit(zld.gpa);
// Write load commands
var lc_buffer = std.ArrayList(u8).init(arena);