Compare commits

...

5 commits

Author SHA1 Message Date
Eduard Voronkin
2d194a0e7c
Merge 1cede1c9ee into fae61ed946 2025-04-14 10:09:15 +02:00
Daan
fae61ed946 fix assertion in mi_free_size (issue #754) 2025-04-13 19:56:49 -07:00
Daan
a5298dd48f Merge remote-tracking branch 'refs/remotes/origin/dev' into dev 2025-04-13 19:50:59 -07:00
Daan
7543e8989a validate pointer before assertion in mi_free_size (issue #754) 2025-04-13 19:49:47 -07:00
Eduard Voronkin
1cede1c9ee init main heap 2025-03-31 21:33:07 -07:00
2 changed files with 5 additions and 1 deletions

View file

@ -340,7 +340,10 @@ mi_decl_nodiscard size_t mi_usable_size(const void* p) mi_attr_noexcept {
void mi_free_size(void* p, size_t size) mi_attr_noexcept { void mi_free_size(void* p, size_t size) mi_attr_noexcept {
MI_UNUSED_RELEASE(size); MI_UNUSED_RELEASE(size);
mi_assert(p == NULL || size <= _mi_usable_size(p,"mi_free_size")); #if MI_DEBUG
const size_t available = _mi_usable_size(p,"mi_free_size");
mi_assert(p == NULL || size <= available || available == 0 /* invalid pointer */ );
#endif
mi_free(p); mi_free(p);
} }

View file

@ -207,6 +207,7 @@ static void mi_heap_main_init(void) {
if (_mi_heap_main.cookie == 0) { if (_mi_heap_main.cookie == 0) {
_mi_heap_main.thread_id = _mi_thread_id(); _mi_heap_main.thread_id = _mi_thread_id();
_mi_heap_main.cookie = 1; _mi_heap_main.cookie = 1;
mi_thread_init();
#if defined(_WIN32) && !defined(MI_SHARED_LIB) #if defined(_WIN32) && !defined(MI_SHARED_LIB)
_mi_random_init_weak(&_mi_heap_main.random); // prevent allocation failure during bcrypt dll initialization with static linking _mi_random_init_weak(&_mi_heap_main.random); // prevent allocation failure during bcrypt dll initialization with static linking
#else #else