Always set memptr in posix_memalign()

This commit is contained in:
Peter Limkilde Svendsen
2020-05-24 18:29:57 +02:00
parent 60b23003c7
commit da8d2fa7aa
+5 -4
View File
@@ -647,13 +647,14 @@ pub unsafe extern "C" fn posix_memalign(
if alignment % VOID_PTR_SIZE == 0 && alignment.is_power_of_two() {
let ptr = platform::alloc_align(size, alignment);
if !ptr.is_null() {
*memptr = ptr;
0
} else {
*memptr = ptr;
if ptr.is_null() {
ENOMEM
} else {
0
}
} else {
*memptr = ptr::null_mut();
EINVAL
}
}