Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some calls to free() missing alignment #3639

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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