| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -828,6 +828,10 @@ static bool mi_manage_os_memory_ex2(void* start, size_t size, bool is_large, int | |||
| 828 | 828 | _mi_warning_message("the arena size is too small (memory at %p with size %zu)\n", start, size); | |
| 829 | 829 | return false; | |
| 830 | 830 | } | |
| 831 | + if (size > MI_MAX_ALLOC_SIZE) { | ||
| 832 | + _mi_error_message(EOVERFLOW, "the arena size is too large (memory at %p with size %zu)\n", start, size); | ||
| 833 | + return false; | ||
| 834 | + } | ||
| 831 | 835 | if (is_large) { | |
| 832 | 836 | mi_assert_internal(memid.initially_committed && memid.is_pinned); | |
| 833 | 837 | } | |
@@ -898,7 +902,13 @@ bool mi_manage_os_memory_ex(void* start, size_t size, bool is_committed, bool is | |||
| 898 | 902 | // Reserve a range of regular OS memory | |
| 899 | 903 | int mi_reserve_os_memory_ex(size_t size, bool commit, bool allow_large, bool exclusive, mi_arena_id_t* arena_id) mi_attr_noexcept { | |
| 900 | 904 | if (arena_id != NULL) *arena_id = _mi_arena_id_none(); | |
| 901 | - size = _mi_align_up(size, MI_ARENA_BLOCK_SIZE); // at least one block | ||
| 905 | + if (size < MI_MAX_ALLOC_SIZE) { | ||
| 906 | + size = _mi_align_up(size, MI_ARENA_BLOCK_SIZE); // at least one block | ||
| 907 | + } | ||
| 908 | + if (size > MI_MAX_ALLOC_SIZE) { | ||
| 909 | + _mi_error_message(EOVERFLOW, "memory reservation request is too large (size %zu)\n", size); | ||
| 910 | + return ENOMEM; | ||
| 911 | + } | ||
| 902 | 912 | mi_memid_t memid; | |
| 903 | 913 | void* start = _mi_os_alloc_aligned(size, MI_SEGMENT_ALIGN, commit, allow_large, &memid); | |
| 904 | 914 | if (start == NULL) return ENOMEM; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments