Commit b642bb92e5

Techatrix <19954306+Techatrix@users.noreply.github.com>
2023-09-08 00:03:23
wasm-linker: fix use of invalidated memory in populateErrorNameTable
1 parent 9126852
Changed files (1)
src
src/link/Wasm.zig
@@ -3005,7 +3005,6 @@ pub fn getErrorTableSymbol(wasm: *Wasm) !u32 {
 fn populateErrorNameTable(wasm: *Wasm) !void {
     const symbol_index = wasm.error_table_symbol orelse return;
     const atom_index = wasm.symbol_atom.get(.{ .file = null, .index = symbol_index }).?;
-    const atom = wasm.getAtomPtr(atom_index);
 
     // Rather than creating a symbol for each individual error name,
     // we create a symbol for the entire region of error names. We then calculate
@@ -3030,6 +3029,8 @@ fn populateErrorNameTable(wasm: *Wasm) !void {
     var addend: u32 = 0;
     const mod = wasm.base.options.module.?;
     for (mod.global_error_set.keys()) |error_name_nts| {
+        const atom = wasm.getAtomPtr(atom_index);
+
         const error_name = mod.intern_pool.stringToSlice(error_name_nts);
         const len = @as(u32, @intCast(error_name.len + 1)); // names are 0-termianted