sim: fix kasan report memalign crash when alignment is 1
(0)Allocating 3 bytes aligned to 0x00000001 ================================================================= ==1461685==ERROR: AddressSanitizer: invalid alignment requested in posix_memalign: 1, alignment must be a power of two and a multiple of sizeof(void*) == 4 (thread T0) #0 0xf7ab1c2f in __interceptor_posix_memalign ../../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:226 Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
8d0094f6c9
commit
24cdcd9a6e
|
@ -156,6 +156,11 @@ void *host_memalign(size_t alignment, size_t size)
|
||||||
void *p;
|
void *p;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
if (alignment < sizeof(void *))
|
||||||
|
{
|
||||||
|
alignment = sizeof(void *);
|
||||||
|
}
|
||||||
|
|
||||||
error = posix_memalign(&p, alignment, size);
|
error = posix_memalign(&p, alignment, size);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue