mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-04 22:49:32 +03:00
add check for overflowing size allocation
This commit is contained in:
parent
12d756e7b2
commit
1e636c45da
1 changed files with 6 additions and 1 deletions
|
@ -694,7 +694,12 @@ void* _mi_malloc_generic(mi_heap_t* heap, size_t size) mi_attr_noexcept
|
||||||
// huge allocation?
|
// huge allocation?
|
||||||
mi_page_t* page;
|
mi_page_t* page;
|
||||||
if (mi_unlikely(size > MI_LARGE_SIZE_MAX)) {
|
if (mi_unlikely(size > MI_LARGE_SIZE_MAX)) {
|
||||||
page = mi_huge_page_alloc(heap,size);
|
if (mi_unlikely(size >= (SIZE_MAX - MI_MAX_ALIGN_SIZE))) {
|
||||||
|
page = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
page = mi_huge_page_alloc(heap,size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// otherwise find a page with free blocks in our size segregated queues
|
// otherwise find a page with free blocks in our size segregated queues
|
||||||
|
|
Loading…
Add table
Reference in a new issue