Skip to content

Commit b642bb9

Browse files
Techatrixkubkon
authored andcommitted
wasm-linker: fix use of invalidated memory in populateErrorNameTable
1 parent 9126852 commit b642bb9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/link/Wasm.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3005,7 +3005,6 @@ pub fn getErrorTableSymbol(wasm: *Wasm) !u32 {
30053005
fn populateErrorNameTable(wasm: *Wasm) !void {
30063006
const symbol_index = wasm.error_table_symbol orelse return;
30073007
const atom_index = wasm.symbol_atom.get(.{ .file = null, .index = symbol_index }).?;
3008-
const atom = wasm.getAtomPtr(atom_index);
30093008

30103009
// Rather than creating a symbol for each individual error name,
30113010
// we create a symbol for the entire region of error names. We then calculate
@@ -3030,6 +3029,8 @@ fn populateErrorNameTable(wasm: *Wasm) !void {
30303029
var addend: u32 = 0;
30313030
const mod = wasm.base.options.module.?;
30323031
for (mod.global_error_set.keys()) |error_name_nts| {
3032+
const atom = wasm.getAtomPtr(atom_index);
3033+
30333034
const error_name = mod.intern_pool.stringToSlice(error_name_nts);
30343035
const len = @as(u32, @intCast(error_name.len + 1)); // names are 0-termianted
30353036

0 commit comments

Comments
 (0)