diff options
author | ed <ed@FreeBSD.org> | 2013-05-27 18:27:12 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2013-05-27 18:27:12 +0000 |
commit | 2f7fa77a0a85c00fd0cce298851e9577b98ccfe8 (patch) | |
tree | 50f0ab80515576749ef638dd0766b70a65904bfa /lib/tsan/lit_tests/malloc_overflow.cc | |
parent | 254a83b703ce3576b1aea35fdd5308aaf1d05f4b (diff) | |
download | FreeBSD-src-2f7fa77a0a85c00fd0cce298851e9577b98ccfe8.zip FreeBSD-src-2f7fa77a0a85c00fd0cce298851e9577b98ccfe8.tar.gz |
Import compiler-rt r182741.
Diffstat (limited to 'lib/tsan/lit_tests/malloc_overflow.cc')
-rw-r--r-- | lib/tsan/lit_tests/malloc_overflow.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/tsan/lit_tests/malloc_overflow.cc b/lib/tsan/lit_tests/malloc_overflow.cc new file mode 100644 index 0000000..19423c5 --- /dev/null +++ b/lib/tsan/lit_tests/malloc_overflow.cc @@ -0,0 +1,22 @@ +// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s +#include <stdio.h> +#include <stdlib.h> + +int main() { + void *p = malloc((size_t)-1); + if (p != 0) + printf("FAIL malloc(-1) = %p\n", p); + p = malloc((size_t)-1 / 2); + if (p != 0) + printf("FAIL malloc(-1/2) = %p\n", p); + p = calloc((size_t)-1, (size_t)-1); + if (p != 0) + printf("FAIL calloc(-1, -1) = %p\n", p); + p = calloc((size_t)-1 / 2, (size_t)-1 / 2); + if (p != 0) + printf("FAIL calloc(-1/2, -1/2) = %p\n", p); + printf("OK\n"); +} + +// CHECK-NOT: FAIL +// CHECK-NOT: failed to allocate |