mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-14 20:11:37 +03: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:
parent
6e3e9d2dae
commit
5aee2f9c6a
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user