Skip to content

Commit cd4d1c7

Browse files
authored
Rollup merge of #70585 - alexcrichton:fix-wasi-align-alloc, r=Mark-Simulacrum
std: Fix over-aligned allocations on wasm32-wasi The wasm32-wasi target delegates its malloc implementation to the functions in wasi-libc, but the invocation of `aligned_alloc` was incorrect by passing the number of bytes requested first rather than the alignment. This commit swaps the order of these two arguments to ensure that we allocate over-aligned memory correctly.
2 parents 3ef70fe + ab2998b commit cd4d1c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/sys/wasi/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ unsafe impl GlobalAlloc for System {
1010
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
1111
libc::malloc(layout.size()) as *mut u8
1212
} else {
13-
libc::aligned_alloc(layout.size(), layout.align()) as *mut u8
13+
libc::aligned_alloc(layout.align(), layout.size()) as *mut u8
1414
}
1515
}
1616

0 commit comments

Comments
 (0)