mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-12 22:24:58 +03:00
fix bug in secure mode where adjustment would make the page size less than the blocksize on the first page of a segment
This commit is contained in:
parent
d3715132d1
commit
3eb616f2bf
2 changed files with 8 additions and 5 deletions
|
@ -403,12 +403,14 @@ uint8_t* _mi_segment_page_start(const mi_segment_t* segment, const mi_page_t* pa
|
|||
if (page->segment_idx == 0 && block_size > 0 && segment->page_kind <= MI_PAGE_MEDIUM) {
|
||||
// for small and medium objects, ensure the page start is aligned with the block size (PR#66 by kickunderscore)
|
||||
size_t adjust = block_size - ((uintptr_t)p % block_size);
|
||||
if (adjust < block_size) {
|
||||
p += adjust;
|
||||
psize -= adjust;
|
||||
if (pre_size != NULL) *pre_size = adjust;
|
||||
if (psize - adjust >= block_size) {
|
||||
if (adjust < block_size) {
|
||||
p += adjust;
|
||||
psize -= adjust;
|
||||
if (pre_size != NULL) *pre_size = adjust;
|
||||
}
|
||||
mi_assert_internal((uintptr_t)p % block_size == 0);
|
||||
}
|
||||
mi_assert_internal((uintptr_t)p % block_size == 0);
|
||||
}
|
||||
|
||||
if (page_size != NULL) *page_size = psize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue