zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit d0d0847cd0f9fcb190c9460fc090f3a1891ad443 (tree)
parent e5d78f0b5550b69b29fb59885d159edbfac8b7d5
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sat, 11 Jan 2025 19:04:16 -0800

wasm linker: don't crash on ref to void

Diffstat:
Msrc/link/Wasm.zig | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig @@ -4376,7 +4376,8 @@ pub fn navAddr(wasm: *Wasm, nav_index: InternPool.Nav.Index) u32 { assert(wasm.flush_buffer.memory_layout_finished); const comp = wasm.base.comp; assert(comp.config.output_mode != .Obj); - const navs_exe_index: NavsExeIndex = @enumFromInt(wasm.navs_exe.getIndex(nav_index).?); + // If there is no entry it means the value is zero bits so any address will do. + const navs_exe_index: NavsExeIndex = @enumFromInt(wasm.navs_exe.getIndex(nav_index) orelse return 0); log.debug("navAddr {s} {}", .{ navs_exe_index.name(wasm), nav_index }); const ds_id: DataSegmentId = .pack(wasm, .{ .nav_exe = navs_exe_index }); return wasm.flush_buffer.data_segments.get(ds_id).?;