Skip to content

Commit

Permalink
Fix some calls to free() missing alignment (#3639)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Oct 3, 2023
1 parent f117406 commit 9e80eb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -132,6 +132,9 @@
* Fix bug with function arguments coming from `macro_rules!`.
[#3625](https://github.com/rustwasm/wasm-bindgen/pull/3625)

* Fix some calls to `free()` missing alignment.
[#3639](https://github.com/rustwasm/wasm-bindgen/pull/3639)

### Removed

* Removed `ReadableStreamByobReader::read_with_u8_array()` because it doesn't work with Wasm.
Expand Down
10 changes: 5 additions & 5 deletions crates/cli-support/src/js/binding.rs
Expand Up @@ -1056,7 +1056,7 @@ fn instruction(
if *owned {
let free = js.cx.export_name_of(*free);
js.prelude(&format!(
"if ({ptr} !== 0) {{ wasm.{}({ptr}, {len}); }}",
"if ({ptr} !== 0) {{ wasm.{}({ptr}, {len}, 1); }}",
free,
ptr = ptr,
len = len,
Expand Down Expand Up @@ -1129,11 +1129,11 @@ fn instruction(
let free = js.cx.export_name_of(*free);
js.prelude(&format!("var v{} = {}({}, {}).slice();", i, f, ptr, len));
js.prelude(&format!(
"wasm.{}({}, {} * {});",
"wasm.{}({}, {} * {size}, {size});",
free,
ptr,
len,
kind.size()
size = kind.size()
));
js.push(format!("v{}", i))
}
Expand All @@ -1148,11 +1148,11 @@ fn instruction(
js.prelude(&format!("if ({} !== 0) {{", ptr));
js.prelude(&format!("v{} = {}({}, {}).slice();", i, f, ptr, len));
js.prelude(&format!(
"wasm.{}({}, {} * {});",
"wasm.{}({}, {} * {size}, {size});",
free,
ptr,
len,
kind.size()
size = kind.size()
));
js.prelude("}");
js.push(format!("v{}", i));
Expand Down

0 comments on commit 9e80eb2

Please sign in to comment.