mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 06:59:32 +03:00
add check for if commit fails in segment allocation
This commit is contained in:
parent
15bb20f9e6
commit
0d3c141243
1 changed files with 6 additions and 1 deletions
|
@ -627,8 +627,13 @@ static mi_segment_t* mi_segment_init(mi_segment_t* segment, size_t required, mi_
|
||||||
if (!commit) {
|
if (!commit) {
|
||||||
// ensure the initial info is committed
|
// ensure the initial info is committed
|
||||||
bool commit_zero = false;
|
bool commit_zero = false;
|
||||||
_mi_mem_commit(segment, pre_size, &commit_zero, tld->os);
|
bool ok = _mi_mem_commit(segment, pre_size, &commit_zero, tld->os);
|
||||||
if (commit_zero) is_zero = true;
|
if (commit_zero) is_zero = true;
|
||||||
|
if (!ok) {
|
||||||
|
// commit failed; we cannot touch the memory: free the segment directly and return `NULL`
|
||||||
|
_mi_mem_free(segment, MI_SEGMENT_SIZE, memid, false, false, os_tld);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
segment->memid = memid;
|
segment->memid = memid;
|
||||||
segment->mem_is_fixed = mem_large;
|
segment->mem_is_fixed = mem_large;
|
||||||
|
|
Loading…
Add table
Reference in a new issue