mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
wasm: incorrect step used to read RocList elements
This commit is contained in:
parent
8c46ab95f2
commit
73d4a4ee56
3 changed files with 44 additions and 12 deletions
|
@ -91,15 +91,11 @@ impl<T: FromWasm32Memory + Clone> FromWasm32Memory for RocList<T> {
|
|||
let capacity =
|
||||
<u32 as FromWasm32Memory>::decode(memory, offset + 4 * Builtin::WRAPPER_CAPACITY);
|
||||
|
||||
let mut items = Vec::with_capacity(length as usize);
|
||||
let step = <T as Wasm32Sized>::SIZE_OF_WASM;
|
||||
|
||||
for i in 0..length {
|
||||
let item = <T as FromWasm32Memory>::decode(
|
||||
memory,
|
||||
elements + i * <T as Wasm32Sized>::SIZE_OF_WASM as u32,
|
||||
);
|
||||
items.push(item);
|
||||
}
|
||||
let items: Vec<_> = (0..length)
|
||||
.map(|i| <T as FromWasm32Memory>::decode(memory, elements + i * step as u32))
|
||||
.collect();
|
||||
|
||||
let mut list = RocList::with_capacity(capacity as usize);
|
||||
list.extend_from_slice(&items);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue