diff options
Diffstat (limited to 'lib/asan/output_tests/interception_malloc_test-linux.cc')
-rw-r--r-- | lib/asan/output_tests/interception_malloc_test-linux.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/asan/output_tests/interception_malloc_test-linux.cc b/lib/asan/output_tests/interception_malloc_test-linux.cc new file mode 100644 index 0000000..4bb3bd6 --- /dev/null +++ b/lib/asan/output_tests/interception_malloc_test-linux.cc @@ -0,0 +1,19 @@ +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> + +extern "C" void *__interceptor_malloc(size_t size); +extern "C" void *malloc(size_t size) { + write(2, "malloc call\n", sizeof("malloc call\n") - 1); + return __interceptor_malloc(size); +} + +int main() { + char *x = (char*)malloc(10 * sizeof(char)); + free(x); + return (int)strtol(x, 0, 10); +} + +// Check-Common: malloc call +// Check-Common: heap-use-after-free + |