summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-06-30 16:47:48 -0400
committerJakob Kaivo <jkk@ung.org>2020-06-30 16:47:48 -0400
commit543c1d44711c4a4cd1ee52c3717abfe2c79b344a (patch)
tree36ca054153361bf60ae0aefcc5f1db5cf0aaf491 /test
parentaacd5c7f5eb7e9a247e453a13ce7534bd28aed34 (diff)
add tests for attempting to free() or realloc() on an invalid address
Diffstat (limited to 'test')
-rw-r--r--test/invalid-free.c12
-rw-r--r--test/invalid-realloc.c12
2 files changed, 24 insertions, 0 deletions
diff --git a/test/invalid-free.c b/test/invalid-free.c
new file mode 100644
index 0000000..5aba5e6
--- /dev/null
+++ b/test/invalid-free.c
@@ -0,0 +1,12 @@
+#define _POSIX_C_SOURCE 200809L
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "mapalloc.h"
+
+int main(void)
+{
+ int foo = 42;
+ MA_free(&foo);
+ printf("freed\n");
+}
diff --git a/test/invalid-realloc.c b/test/invalid-realloc.c
new file mode 100644
index 0000000..f60bedc
--- /dev/null
+++ b/test/invalid-realloc.c
@@ -0,0 +1,12 @@
+#define _POSIX_C_SOURCE 200809L
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "mapalloc.h"
+
+int main(void)
+{
+ int foo = 42;
+ int *ptr = MA_realloc(&foo, sizeof(int));
+ printf("%d\n", *ptr);
+}