git: 05fe8c88e1ce - stable/14 - libc: lib_malloc_aligned(): add a missing NULL check
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 28 Aug 2025 13:55:22 UTC
The branch stable/14 has been updated by sobomax:
URL: https://cgit.FreeBSD.org/src/commit/?id=05fe8c88e1ce7904a14997a5e5e253d92fbe3e42
commit 05fe8c88e1ce7904a14997a5e5e253d92fbe3e42
Author: Maxim Sobolev <sobomax@FreeBSD.org>
AuthorDate: 2024-12-08 19:08:43 +0000
Commit: Maxim Sobolev <sobomax@FreeBSD.org>
CommitDate: 2025-08-28 13:54:34 +0000
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
(cherry picked from commit 1e99be5dcda222d47a77715e190a381a14f46ece)
---
lib/libc/gen/tls.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c
index 3c1a5472c0e5..30b4fc583c98 100644
--- a/lib/libc/gen/tls.c
+++ b/lib/libc/gen/tls.c
@@ -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);