mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 15:09:31 +03:00
fix possible underflow (issue #731)
This commit is contained in:
parent
b549c88e6c
commit
4cb5b45178
1 changed files with 6 additions and 3 deletions
|
@ -1273,10 +1273,13 @@ void _mi_segment_huge_page_reset(mi_segment_t* segment, mi_page_t* page, mi_bloc
|
||||||
mi_assert_internal(page->used == 1); // this is called just before the free
|
mi_assert_internal(page->used == 1); // this is called just before the free
|
||||||
mi_assert_internal(page->free == NULL);
|
mi_assert_internal(page->free == NULL);
|
||||||
if (segment->allow_decommit && page->is_committed) {
|
if (segment->allow_decommit && page->is_committed) {
|
||||||
const size_t usize = mi_usable_size(block) - sizeof(mi_block_t);
|
size_t usize = mi_usable_size(block);
|
||||||
|
if (usize > sizeof(mi_block_t)) {
|
||||||
|
usize = usize - sizeof(mi_block_t);
|
||||||
uint8_t* p = (uint8_t*)block + sizeof(mi_block_t);
|
uint8_t* p = (uint8_t*)block + sizeof(mi_block_t);
|
||||||
_mi_os_reset(p, usize, &_mi_stats_main);
|
_mi_os_reset(p, usize, &_mi_stats_main);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue