summaryrefslogtreecommitdiff
path: root/test/use-after-free.c
blob: c7ae9cb6c78ec12739d33f10369d093a646089f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "mapalloc.h"

int main(void)
{
	const char buf[] = "THIS IS A CONSTANT STRING";

	char *ptr = MA_malloc(sizeof(buf));
	memcpy(ptr, buf, sizeof(buf));
	printf("%p: %s\n", ptr, ptr);

	MA_free(ptr);
	printf("freed\n");
	printf("%p: %s\n", ptr, ptr);
}