summaryrefslogtreecommitdiff
path: root/test/double-free.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-06-30 13:38:00 -0400
committerJakob Kaivo <jkk@ung.org>2020-06-30 13:38:00 -0400
commit3c55d2c9a122091db77b735120c3bf5aa29722ad (patch)
treec40a8f2e5dbe80a86d809efcae21051142e03491 /test/double-free.c
parent624ac93ac5673cf88a426de054d36c61503c1779 (diff)
add tests for double free() and use after free()
Diffstat (limited to 'test/double-free.c')
-rw-r--r--test/double-free.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/double-free.c b/test/double-free.c
new file mode 100644
index 0000000..73ceff5
--- /dev/null
+++ b/test/double-free.c
@@ -0,0 +1,19 @@
+#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 = map_malloc(sizeof(buf));
+ memcpy(ptr, buf, sizeof(buf));
+ printf("%p: %s\n", ptr, ptr);
+
+ map_free(ptr);
+ printf("freed\n");
+ map_free(ptr);
+ printf("freed again\n");
+}