projects
/
musl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2c00f95
)
mallocng/aligned_alloc: check for malloc failure
author
Dominic Chen
<d.c.ddcc@gmail.com>
Thu, 25 Mar 2021 22:20:14 +0000
(18:20 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Fri, 16 Apr 2021 14:17:25 +0000
(10:17 -0400)
With mallocng, calling posix_memalign() or aligned_alloc() will
SIGSEGV if the internal malloc() call returns NULL. This does not
occur with oldmalloc, which explicitly checks for allocation failure.
src/malloc/mallocng/aligned_alloc.c
patch
|
blob
|
history
diff --git
a/src/malloc/mallocng/aligned_alloc.c
b/src/malloc/mallocng/aligned_alloc.c
index
3411689
..
e0862a8
100644
(file)
--- a/
src/malloc/mallocng/aligned_alloc.c
+++ b/
src/malloc/mallocng/aligned_alloc.c
@@
-22,6
+22,9
@@
void *aligned_alloc(size_t align, size_t len)
if (align <= UNIT) align = UNIT;
unsigned char *p = malloc(len + align - UNIT);
+ if (!p)
+ return 0;
+
struct meta *g = get_meta(p);
int idx = get_slot_index(p);
size_t stride = get_stride(g);