mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-21 12:42:25 +00:00
arena: do not memset a NULL pointer when posix_memalign fails
The memset was run unconditionally after posix_memalign, so an allocation failure crashed in memset instead of returning NULL to the caller, defeating the OOM handling in every arena user.
This commit is contained in:
parent
5a1341a4d9
commit
dd25eb8538
1 changed files with 1 additions and 1 deletions
|
|
@ -52,7 +52,7 @@ MA_CAT(MA_NAME, _get)(MA_TYPE_NAME *self, size_t sz) {
|
|||
void *chunk = NULL;
|
||||
if (MA_BLOCK_SIZE >= sizeof(void *) && MA_BLOCK_SIZE % sizeof(void *) == 0) {
|
||||
if (posix_memalign(&chunk, MA_BLOCK_SIZE, block_sz) != 0) chunk = NULL;
|
||||
memset(chunk, 0, block_sz);
|
||||
else memset(chunk, 0, block_sz);
|
||||
} else chunk = calloc(1, block_sz);
|
||||
if (!chunk) { return NULL; }
|
||||
if (count > self->capacity) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue