Skip to content

Commit 1590c9d

Browse files
committed
std::alloc: checking if the alignment is, at least, a word size.
so we do not error (at least on solarish systems) in that case. close GH-124787
1 parent 8cef37d commit 1590c9d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/std/src/sys/pal/unix/alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ cfg_if::cfg_if! {
8181
// [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579
8282
// [4]: https://chromium.googlesource.com/chromium/src/base/+/master/
8383
// /memory/aligned_memory.cc
84-
libc::memalign(layout.align(), layout.size()) as *mut u8
84+
if layout.align() >= crate::mem::size_of::<usize>() { libc::memalign(layout.align(), layout.size()) as *mut u8 } else { ptr::null_mut() }
8585
}
8686
} else if #[cfg(target_os = "wasi")] {
8787
#[inline]

0 commit comments

Comments
 (0)