mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
add pointer validity check in debug mode for mi_usable_size/mi_realloc/mi_expand. Issue #269
This commit is contained in:
parent
457fcbd9d5
commit
8769082d63
2 changed files with 54 additions and 32 deletions
|
@ -11,6 +11,7 @@ static void double_free1();
|
|||
static void double_free2();
|
||||
static void corrupt_free();
|
||||
static void block_overflow1();
|
||||
static void invalid_free();
|
||||
|
||||
int main() {
|
||||
mi_version();
|
||||
|
@ -19,7 +20,8 @@ int main() {
|
|||
// double_free1();
|
||||
// double_free2();
|
||||
// corrupt_free();
|
||||
block_overflow1();
|
||||
// block_overflow1();
|
||||
invalid_free();
|
||||
|
||||
void* p1 = malloc(78);
|
||||
void* p2 = malloc(24);
|
||||
|
@ -43,6 +45,11 @@ int main() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void invalid_free() {
|
||||
free((void*)0xBADBEEF);
|
||||
realloc((void*)0xBADBEEF,10);
|
||||
}
|
||||
|
||||
static void block_overflow1() {
|
||||
uint8_t* p = (uint8_t*)mi_malloc(17);
|
||||
p[18] = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue