mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-10 17:29:31 +03:00
Merge branch 'dev-trace' into dev-slice-trace
This commit is contained in:
commit
c56f3e0bb3
1 changed files with 37 additions and 0 deletions
37
test/test-overflow.cpp
Normal file
37
test/test-overflow.cpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
#include <vector>
|
||||||
|
#include <future>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <assert.h>
|
||||||
|
static void block_overflow1(void) {
|
||||||
|
uint8_t* p = (uint8_t*)malloc(17);
|
||||||
|
p[18] = 0;
|
||||||
|
free(p);
|
||||||
|
uint8_t* q = (uint8_t*)malloc(17);
|
||||||
|
free(p);
|
||||||
|
free(q);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OVF_SIZE 100
|
||||||
|
|
||||||
|
static void block_overflow2(void) {
|
||||||
|
uint8_t* p = (uint8_t*)malloc(30);
|
||||||
|
memset(p+30, 0, OVF_SIZE);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
printf("test overflow..\n");
|
||||||
|
block_overflow1();
|
||||||
|
block_overflow2();
|
||||||
|
printf("done..\n");
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue