improve handling of out-of-memory situations

This commit is contained in:
daan 2020-09-14 09:02:06 -07:00
parent ff7b6c54bd
commit 840eba2874
2 changed files with 13 additions and 11 deletions

View file

@ -207,14 +207,16 @@ static void mi_segment_protect(mi_segment_t* segment, bool protect, mi_os_tld_t*
mi_assert_internal(MI_SECURE <= 1 || segment->page_kind >= MI_PAGE_LARGE);
uint8_t* start = (uint8_t*)segment + segment->segment_size - os_psize;
if (protect && !segment->mem_is_committed) {
// ensure secure page is committed
#if (MI_DEBUG>1)
bool ok =
#endif
_mi_mem_commit(start, os_psize, NULL, tld);
mi_assert_internal(ok);
if (protect) {
// ensure secure page is committed
if (_mi_mem_commit(start, os_psize, NULL, tld)) { // if this fails that is ok (as it is an unaccessible page)
mi_segment_protect_range(start, os_psize, protect);
}
}
}
else {
mi_segment_protect_range(start, os_psize, protect);
}
mi_segment_protect_range(start, os_psize, protect);
}
else {
// or protect every page