diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-31 15:59:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-31 15:59:47 +0200 |
| commit | cd4d1c7f6d69ed05008cb3832272d4466950f5ad (patch) | |
| tree | 6004191dc0dd34c425dbda7a3d7793a7e84eb2d1 /src/libstd | |
| parent | 3ef70fe156be1f8236c23a49c0db841207895ef9 (diff) | |
| parent | ab2998bac3bd7ae254cacad3f0911c950691216a (diff) | |
| download | rust-cd4d1c7f6d69ed05008cb3832272d4466950f5ad.tar.gz rust-cd4d1c7f6d69ed05008cb3832272d4466950f5ad.zip | |
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.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sys/wasi/alloc.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/sys/wasi/alloc.rs b/src/libstd/sys/wasi/alloc.rs index e9760d050e1..bc614162784 100644 --- a/src/libstd/sys/wasi/alloc.rs +++ b/src/libstd/sys/wasi/alloc.rs @@ -10,7 +10,7 @@ unsafe impl GlobalAlloc for System { if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { libc::malloc(layout.size()) as *mut u8 } else { - libc::aligned_alloc(layout.size(), layout.align()) as *mut u8 + libc::aligned_alloc(layout.align(), layout.size()) as *mut u8 } } |
