• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: LSAN_BASE="use_registers=0:use_stacks=0"
2 // RUN: %clangxx_lsan %s -o %t
3 // RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
4 
5 #include <stdio.h>
6 #include <stdlib.h>
7 
8 #include "sanitizer/lsan_interface.h"
9 
10 extern "C"
__lsan_default_suppressions()11 const char *__lsan_default_suppressions() {
12   return "leak:*LSanTestLeakingFunc*";
13 }
14 
LSanTestLeakingFunc()15 void LSanTestLeakingFunc() {
16   void *p = malloc(666);
17   fprintf(stderr, "Test alloc: %p.\n", p);
18 }
19 
main()20 int main() {
21   LSanTestLeakingFunc();
22   void *q = malloc(1337);
23   fprintf(stderr, "Test alloc: %p.\n", q);
24   return 0;
25 }
26 // CHECK: Suppressions used:
27 // CHECK: 1 666 *LSanTestLeakingFunc*
28 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
29