Check the alignment in posix_memalign() earlier

Make sure all conditions to do a proper memory allocation are satisfied
before a zero size memory allocation is performed.

Update #4390.
This commit is contained in:
Sebastian Huber
2021-05-06 19:25:09 +02:00
parent b391affc36
commit c46d125569

View File

@@ -37,10 +37,6 @@ int posix_memalign(
*memptr = NULL;
if ( size == 0 ) {
return 0;
}
if ( alignment < sizeof( void * ) ) {
return EINVAL;
}
@@ -49,6 +45,10 @@ int posix_memalign(
return EINVAL;
}
if ( size == 0 ) {
return 0;
}
*memptr = rtems_heap_allocate_aligned_with_boundary( size, alignment, 0 );
if ( *memptr == NULL ) {