fix assertion

This commit is contained in:
Daan Leijen 2022-04-10 13:27:43 -07:00
parent b4ca31bcd0
commit 9aec70ee02
2 changed files with 5 additions and 5 deletions

View file

@ -302,8 +302,8 @@ static void _mi_show_block_trace(const mi_page_t* page, const mi_block_t* block,
static const mi_block_t* mi_block_predecessor(const mi_page_t* page, const mi_block_t* block) {
const size_t bsize = page->xblock_size;
mi_assert_internal(bsize > 0);
if (bsize >= MI_HUGE_BLOCK_SIZE) return NULL;
mi_assert_internal(bsize > 0 || page->used == 0);
if (bsize == 0 /* if page is freed */|| bsize >= MI_HUGE_BLOCK_SIZE) return NULL;
const mi_block_t* prev = (const mi_block_t*)((uint8_t*)block - bsize);
uint8_t* pstart = _mi_segment_page_start(_mi_page_segment(page), page, NULL);
if (pstart > (uint8_t*)prev) return NULL;

View file

@ -27,15 +27,15 @@ int main() {
mi_version();
mi_stats_reset();
// detect double frees and heap corruption
double_free1();
// double_free1();
// double_free2();
// double_free3();
double_free3();
// corrupt_free1();
// corrupt_free2();
// block_overflow1();
// block_overflow2();
// test_aslr();
invalid_free();
// invalid_free();
// test_reserved();
// negative_stat();
// alloc_huge();