File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
compiler-rt/test/asan/TestCases Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Test for LeakSanitizer+AddressSanitizer of different sizes.
2
+ // REQUIRES: leak-detection
3
+ //
4
+ // RUN: %clangxx_asan -O0 %s -o %t
5
+ // RUN: not %run %t 0 2>&1 | FileCheck %s
6
+ // RUN: not %run %t 1 2>&1 | FileCheck %s
7
+ // RUN: not %run %t 1000 2>&1 | FileCheck %s
8
+ // RUN: not %run %t 1000000 2>&1 | FileCheck %s
9
+ // RUN: not %run %t 10000000 2>&1 | FileCheck %s
10
+
11
+ #include < cstdlib>
12
+ #include < stdio.h>
13
+ #include < thread>
14
+ int *t;
15
+
16
+ __attribute__ ((noopt)) void leak(int n) {
17
+ // Repeat few times to make sure that at least one pointer is
18
+ // not somewhere on the stack.
19
+ for (int i = 0 ; i < 10 ; ++i) {
20
+ t = new int [n];
21
+ printf (" t: %p\n " , t);
22
+ t = 0 ;
23
+ }
24
+ }
25
+
26
+ int main (int argc, char **argv) {
27
+ leak (atoi (argv[1 ]));
28
+ }
29
+ // CHECK: LeakSanitizer: detected memory leaks
You can’t perform that action at this time.
0 commit comments