mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-28 03:13:09 +03:00
Fix pointer arithmetic undefined behavior.
Reported by Denis Denisov.
This commit is contained in:
parent
9cf2be0a81
commit
2012d5a560
2 changed files with 31 additions and 17 deletions
11
src/arena.c
11
src/arena.c
|
|
@ -690,8 +690,10 @@ arena_chunk_ralloc_huge_shrink(arena_t *arena, void *chunk, size_t oldsize,
|
|||
}
|
||||
arena->nactive -= udiff >> LG_PAGE;
|
||||
malloc_mutex_unlock(&arena->lock);
|
||||
if (cdiff != 0)
|
||||
chunk_dalloc(chunk + CHUNK_CEILING(usize), cdiff, arena->ind);
|
||||
if (cdiff != 0) {
|
||||
chunk_dalloc((void *)((uintptr_t)chunk + CHUNK_CEILING(usize)),
|
||||
cdiff, arena->ind);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -714,8 +716,9 @@ arena_chunk_ralloc_huge_expand(arena_t *arena, void *chunk, size_t oldsize,
|
|||
arena->nactive += (udiff >> LG_PAGE);
|
||||
malloc_mutex_unlock(&arena->lock);
|
||||
|
||||
if (chunk_alloc_arena(chunk_alloc, chunk_dalloc, arena->ind, chunk +
|
||||
CHUNK_CEILING(oldsize), cdiff, chunksize, zero) == NULL) {
|
||||
if (chunk_alloc_arena(chunk_alloc, chunk_dalloc, arena->ind,
|
||||
(void *)((uintptr_t)chunk + CHUNK_CEILING(oldsize)), cdiff,
|
||||
chunksize, zero) == NULL) {
|
||||
/* Revert optimistic stats updates. */
|
||||
malloc_mutex_lock(&arena->lock);
|
||||
if (config_stats) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue