Use after free
How it works ?
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(void) {
char *pointer_1 = (char *)malloc(20);
strcpy(pointer_1, "value 1");
printf("pointer 1 : %p, value : %s \n", pointer_1, pointer_1);
free(pointer_1); // Here the pointer_1 is freed but not clear.
char *pointer_2 = (char *)malloc(20);
strcpy(pointer_2, "value 2");
printf("pointer 1 : %p, value : %s \n", pointer_1, pointer_1);
printf("pointer 2 : %p, value : %s \n", pointer_2, pointer_2);
}Resources
Last updated