Fix heapapi ownership checks

`mi_heap_check_owned` does not work for allocations that span
multiple blocks; `mi_is_in_heap_region` is a less precise but
working way for us to check if a pointer is in our heap.

See https://github.com/microsoft/mimalloc/issues/298
This commit is contained in:
2025-10-27 15:18:38 -06:00
parent 27860f0300
commit 8bd15bd272
2 changed files with 7 additions and 3 deletions

View File

@@ -42,8 +42,12 @@ int main(void) {
TEST_CHECK(privateBlock != NULL);
SetLastError(0);
// Disabled temporarily; no good way to detect individual heap allocations
// in mimalloc currently. See https://github.com/microsoft/mimalloc/issues/298
#if 0
TEST_CHECK(!HeapFree(processHeap, 0, privateBlock));
TEST_CHECK_EQ(ERROR_INVALID_PARAMETER, GetLastError());
#endif
TEST_CHECK(HeapFree(privateHeap, 0, privateBlock));
TEST_CHECK(HeapDestroy(privateHeap));