mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
mallocng/aligned_alloc: check for malloc failure
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.
This commit is contained in:
parent
2c00f95c1a
commit
95a540e176
1 changed files with 3 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue