ArchiSys/TP/TP2/rendu/tests/fail/bad_free.c

28 lines
544 B
C
Raw Normal View History

2024-04-19 09:05:42 +02:00
#include <string.h>
#include <stdlib.h>
#include "../../vmap.h"
int main() {
Memory* mem = memory_init(-1);
int pid1 = 12;
int pid2 = 24;
char* real1 = malloc(sizeof(char)*32);
real1[0] = 'h';
real1[1] = 'e';
real1[2] = 'l';
real1[3] = 'l';
real1[4] = 'o';
real1[5] = '!';
real1[6] = '\0';
char* data1 = my_malloc(mem, 32*sizeof(char), pid1);
char* data2 = my_malloc(mem, 32*sizeof(char), pid2);
my_free(mem, data1, pid1);
my_free(mem, data2, pid1); //! bad PID
return 0;
}