mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 15:29:31 +03:00
fix ubsan warning on huge allocations (issue #543)
This commit is contained in:
parent
352d8be237
commit
96008c55d0
1 changed files with 2 additions and 1 deletions
|
@ -762,7 +762,8 @@ static mi_page_t* mi_segment_span_allocate(mi_segment_t* segment, size_t slice_i
|
|||
}
|
||||
|
||||
// and also for the last one (if not set already) (the last one is needed for coalescing)
|
||||
mi_slice_t* last = &segment->slices[slice_index + slice_count - 1];
|
||||
// note: the cast is needed for ubsan since the index can be larger than MI_SLICES_PER_SEGMENT for huge allocations (see #543)
|
||||
mi_slice_t* last = &((mi_slice_t*)segment->slices)[slice_index + slice_count - 1];
|
||||
if (last < mi_segment_slices_end(segment) && last >= slice) {
|
||||
last->slice_offset = (uint32_t)(sizeof(mi_slice_t)*(slice_count-1));
|
||||
last->slice_count = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue