mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 04:51:23 +00:00
Fix an off-by-one in anyref stack manipulation
With more than two anyref stack arguments we were accidentally storing the anyref values one higher in the stack than intended, so fix this off-by-one by switching up some addition logic.
This commit is contained in:
@ -510,14 +510,14 @@ impl Transform<'_> {
|
||||
// Store an anyref at an offset from our function's stack
|
||||
// pointer frame.
|
||||
let get_fp = builder.local_get(fp);
|
||||
next_stack_offset += 1;
|
||||
let (index, idx_local) = if next_stack_offset == 1 {
|
||||
let (index, idx_local) = if next_stack_offset == 0 {
|
||||
(get_fp, fp)
|
||||
} else {
|
||||
let rhs = builder.i32_const(next_stack_offset);
|
||||
let add = builder.binop(BinaryOp::I32Add, get_fp, rhs);
|
||||
(builder.local_tee(scratch_i32, add), scratch_i32)
|
||||
};
|
||||
next_stack_offset += 1;
|
||||
let store = builder.table_set(self.table, index, local);
|
||||
let get = builder.local_get(idx_local);
|
||||
builder.with_side_effects(vec![store], get, Vec::new())
|
||||
|
Reference in New Issue
Block a user