brintos

brintos / llvm-project-archived public Read only

0
0
Text · 636 B · 7404af4 Raw
19 lines · cpp
1// Regression test: pointers to self should not confuse LSan into thinking the2// object is indirectly leaked. Only external pointers count.3// RUN: %clangxx_lsan %s -o %t4// RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0" not %run %t 2>&1 | FileCheck %s5 6#include <stdio.h>7#include <stdlib.h>8#include "sanitizer_common/print_address.h"9 10int main() {11  void *p = malloc(1337);12  *reinterpret_cast<void **>(p) = p;13  print_address("Test alloc: ", 1, p);14}15// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]16// CHECK: LeakSanitizer: detected memory leaks17// CHECK: [[ADDR]] (1337 bytes)18// CHECK: SUMMARY: {{.*}}Sanitizer:19