Skip to content

Commit 317b22c

Browse files
committed
check return value of mi_arena_commit, potential fix for #1098
1 parent c8c325c commit 317b22c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/arena.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ size_t mi_arena_min_alignment(void) {
7676
return MI_ARENA_SLICE_ALIGN;
7777
}
7878

79-
static bool mi_arena_commit(mi_arena_t* arena, void* start, size_t size, bool* is_zero, size_t already_committed) {
79+
mi_decl_nodiscard static bool mi_arena_commit(mi_arena_t* arena, void* start, size_t size, bool* is_zero, size_t already_committed) {
8080
if (arena != NULL && arena->commit_fun != NULL) {
8181
return (*arena->commit_fun)(true, start, size, is_zero, arena->commit_fun_arg);
8282
}
@@ -677,7 +677,10 @@ static mi_page_t* mi_arenas_page_alloc_fresh(size_t slice_count, size_t block_si
677677
commit_size = _mi_align_up(block_start + block_size, MI_PAGE_MIN_COMMIT_SIZE);
678678
if (commit_size > page_noguard_size) { commit_size = page_noguard_size; }
679679
bool is_zero;
680-
mi_arena_commit( mi_memid_arena(memid), page, commit_size, &is_zero, 0);
680+
if (!mi_arena_commit( mi_memid_arena(memid), page, commit_size, &is_zero, 0)) {
681+
_mi_arenas_free(page, alloc_size, memid);
682+
return NULL;
683+
}
681684
if (!memid.initially_zero && !is_zero) {
682685
_mi_memzero_aligned(page, commit_size);
683686
}

0 commit comments

Comments
 (0)