From b93fa9833e6d2f7959eabb2417a154152a8d2d1c Mon Sep 17 00:00:00 2001 From: Luuk de Gram Date: Tue, 16 May 2023 19:33:19 +0200 Subject: [PATCH] wasm: memset - correctly load the ptr for slices Previously we would use the address of the slice itself, which would result in miscompilations and accidently setting the memory region of the slice itself, rather than based on the `ptr` field. --- src/arch/wasm/CodeGen.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index d2a9d1a52fb1816d9f3ce108823e45c8f96e4f93..2d0ee2fc6926c48f390b7043d8a8e667e7f21da6 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -4464,7 +4464,9 @@ fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void .One => @as(WValue, .{ .imm32 = @intCast(u32, ptr_ty.childType().arrayLen()) }), .C, .Many => unreachable, }; - try func.memset(ptr, len, value); + + const dst_ptr = try func.sliceOrArrayPtr(ptr, ptr_ty); + try func.memset(dst_ptr, len, value); func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs }); } -- 2.54.0