We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8cef37d commit 3fddb3bCopy full SHA for 3fddb3b
library/std/src/sys/pal/unix/alloc.rs
@@ -1,4 +1,5 @@
1
use crate::alloc::{GlobalAlloc, Layout, System};
2
+use crate::mem;
3
use crate::ptr;
4
use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};
5
@@ -81,7 +82,7 @@ cfg_if::cfg_if! {
81
82
// [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579
83
// [4]: https://chromium.googlesource.com/chromium/src/base/+/master/
84
// /memory/aligned_memory.cc
- libc::memalign(layout.align(), layout.size()) as *mut u8
85
+ if layout.align() >= mem::size_of::<usize>() { libc::memalign(layout.align(), layout.size()) as *mut u8 } else { ptr::null_mut() }
86
}
87
} else if #[cfg(target_os = "wasi")] {
88
#[inline]
0 commit comments