libc: lib_malloc_aligned(): add a missing NULL check

For some reason return value of the __je_bootstrap_malloc()
is not checked and then de-referenced few lines below, causing
a SEGV if an early allocation fails.

MFC after:      1 month
This commit is contained in:
Maxim Sobolev
2024-12-08 11:08:43 -08:00
parent ae316d1d1c
commit 1e99be5dcd
+2
View File
@@ -113,6 +113,8 @@ libc_malloc_aligned(size_t size, size_t align)
align = sizeof(void *);
mem = __je_bootstrap_malloc(size + sizeof(void *) + align - 1);
if (mem == NULL)
return (NULL);
res = (void *)roundup2((uintptr_t)mem + sizeof(void *), align);
*(void **)((uintptr_t)res - sizeof(void *)) = mem;
return (res);