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