mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-02 01:34:38 +03:00
don't allow allocations larger than PTRDIFF_MAX, issue #121
This commit is contained in:
parent
74299646bb
commit
2066e2797d
1 changed files with 1 additions and 1 deletions
|
@ -741,7 +741,7 @@ 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_OBJ_SIZE_MAX)) {
|
if (mi_unlikely(size > MI_LARGE_OBJ_SIZE_MAX)) {
|
||||||
if (mi_unlikely(size >= (SIZE_MAX - MI_MAX_ALIGN_SIZE))) {
|
if (mi_unlikely(size > PTRDIFF_MAX)) { // we don't allocate more than PTRDIFF_MAX (see <https://sourceware.org/ml/libc-announce/2019/msg00001.html>)
|
||||||
page = NULL;
|
page = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue