diff options
author | Chris Pride <cpride@cpride.net> | 2014-03-26 05:36:05 (GMT) |
---|---|---|
committer | Chris Pride <cpride@cpride.net> | 2014-03-26 05:36:05 (GMT) |
commit | 20a8c78bfe3310e0f0f72b596d4e10ca7336063b (patch) | |
tree | ab971c048ac106bbc3073786333b2430666937a0 /src | |
parent | 9e20df163c0c608026498b8fb5beab35e8a049c6 (diff) | |
download | jemalloc-20a8c78bfe3310e0f0f72b596d4e10ca7336063b.zip jemalloc-20a8c78bfe3310e0f0f72b596d4e10ca7336063b.tar.gz jemalloc-20a8c78bfe3310e0f0f72b596d4e10ca7336063b.tar.bz2 |
Fix a crashing case where arena_chunk_init_hard returns NULL.
This happens when it fails to allocate a new chunk. Which
arena_chunk_alloc then passes into arena_avail_insert without any
checks. This then causes a crash when arena_avail_insert tries
to check chunk->ndirty.
This was introduced by the refactoring of arena_chunk_alloc
which previously would have returned NULL immediately after
calling chunk_alloc. This is now the return from
arena_chunk_init_hard so we need to check that return, and
not continue if it was NULL.
Diffstat (limited to 'src')
-rw-r--r-- | src/arena.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/arena.c b/src/arena.c index 390ab0f..dad707b 100644 --- a/src/arena.c +++ b/src/arena.c @@ -614,8 +614,11 @@ arena_chunk_alloc(arena_t *arena) if (arena->spare != NULL) chunk = arena_chunk_init_spare(arena); - else + else { chunk = arena_chunk_init_hard(arena); + if (chunk == NULL) + return (NULL); + } /* Insert the run into the runs_avail tree. */ arena_avail_insert(arena, chunk, map_bias, chunk_npages-map_bias, |