mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 23:05:24 +00:00
link/Plan9: fix UAF of symbol names
Long term, linker backends will need to manage their own string tables for things like this because my mandate is: no long-lived pointers allowed in any of the codepaths touched by incremental compilation, so that we can serialize and deserialize trivially. Short term, I solved this with a couple calls to Allocator.dupe, incurring some harmless leaks.
This commit is contained in:
parent
4b7c1e5c30
commit
2ad073ec6d
@ -441,7 +441,7 @@ fn updateFinish(self: *Plan9, decl_index: Module.Decl.Index) !void {
|
||||
const sym: aout.Sym = .{
|
||||
.value = undefined, // the value of stuff gets filled in in flushModule
|
||||
.type = decl_block.type,
|
||||
.name = mod.intern_pool.stringToSlice(decl.name),
|
||||
.name = try self.base.allocator.dupe(u8, mod.intern_pool.stringToSlice(decl.name)),
|
||||
};
|
||||
|
||||
if (decl_block.sym_index) |s| {
|
||||
@ -741,7 +741,7 @@ fn addDeclExports(
|
||||
const sym = .{
|
||||
.value = decl_block.offset.?,
|
||||
.type = decl_block.type.toGlobal(),
|
||||
.name = exp_name,
|
||||
.name = try self.base.allocator.dupe(u8, exp_name),
|
||||
};
|
||||
|
||||
if (metadata.getExport(self, exp_name)) |i| {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user