From 35c9e6f16d670f608c68db7304f6eed408eb6186 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 24 Aug 2018 05:53:17 -0400 Subject: [PATCH] add delayed double free tests --- test/simple-memory-corruption/Makefile | 2 ++ .../double_free_large_delayed.c | 17 +++++++++++++++++ .../double_free_small_delayed.c | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 test/simple-memory-corruption/double_free_large_delayed.c create mode 100644 test/simple-memory-corruption/double_free_small_delayed.c diff --git a/test/simple-memory-corruption/Makefile b/test/simple-memory-corruption/Makefile index 4072f0c..e3cf7e1 100644 --- a/test/simple-memory-corruption/Makefile +++ b/test/simple-memory-corruption/Makefile @@ -1,6 +1,8 @@ EXECUTABLES := \ double_free_large \ + double_free_large_delayed \ double_free_small \ + double_free_small_delayed \ unaligned_free_large \ unaligned_free_small \ read_after_free_large \ diff --git a/test/simple-memory-corruption/double_free_large_delayed.c b/test/simple-memory-corruption/double_free_large_delayed.c new file mode 100644 index 0000000..b448ea9 --- /dev/null +++ b/test/simple-memory-corruption/double_free_large_delayed.c @@ -0,0 +1,17 @@ +#include + +__attribute__((optimize(0))) +int main(void) { + void *p = malloc(128 * 1024); + if (!p) { + return 1; + } + void *q = malloc(128 * 1024); + if (!q) { + return 1; + } + free(p); + free(q); + free(p); + return 0; +} diff --git a/test/simple-memory-corruption/double_free_small_delayed.c b/test/simple-memory-corruption/double_free_small_delayed.c new file mode 100644 index 0000000..63d8586 --- /dev/null +++ b/test/simple-memory-corruption/double_free_small_delayed.c @@ -0,0 +1,17 @@ +#include + +__attribute__((optimize(0))) +int main(void) { + void *p = malloc(16); + if (!p) { + return 1; + } + void *q = malloc(16); + if (!q) { + return 1; + } + free(p); + free(q); + free(p); + return 0; +}