Skip to content

Commit 9e80eb2

Browse files
authored
Fix some calls to free() missing alignment (#3639)
1 parent f117406 commit 9e80eb2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
* Fix bug with function arguments coming from `macro_rules!`.
133133
[#3625](https://github.com/rustwasm/wasm-bindgen/pull/3625)
134134

135+
* Fix some calls to `free()` missing alignment.
136+
[#3639](https://github.com/rustwasm/wasm-bindgen/pull/3639)
137+
135138
### Removed
136139

137140
* Removed `ReadableStreamByobReader::read_with_u8_array()` because it doesn't work with Wasm.

crates/cli-support/src/js/binding.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ fn instruction(
10561056
if *owned {
10571057
let free = js.cx.export_name_of(*free);
10581058
js.prelude(&format!(
1059-
"if ({ptr} !== 0) {{ wasm.{}({ptr}, {len}); }}",
1059+
"if ({ptr} !== 0) {{ wasm.{}({ptr}, {len}, 1); }}",
10601060
free,
10611061
ptr = ptr,
10621062
len = len,
@@ -1129,11 +1129,11 @@ fn instruction(
11291129
let free = js.cx.export_name_of(*free);
11301130
js.prelude(&format!("var v{} = {}({}, {}).slice();", i, f, ptr, len));
11311131
js.prelude(&format!(
1132-
"wasm.{}({}, {} * {});",
1132+
"wasm.{}({}, {} * {size}, {size});",
11331133
free,
11341134
ptr,
11351135
len,
1136-
kind.size()
1136+
size = kind.size()
11371137
));
11381138
js.push(format!("v{}", i))
11391139
}
@@ -1148,11 +1148,11 @@ fn instruction(
11481148
js.prelude(&format!("if ({} !== 0) {{", ptr));
11491149
js.prelude(&format!("v{} = {}({}, {}).slice();", i, f, ptr, len));
11501150
js.prelude(&format!(
1151-
"wasm.{}({}, {} * {});",
1151+
"wasm.{}({}, {} * {size}, {size});",
11521152
free,
11531153
ptr,
11541154
len,
1155-
kind.size()
1155+
size = kind.size()
11561156
));
11571157
js.prelude("}");
11581158
js.push(format!("v{}", i));

0 commit comments

Comments
 (0)