summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/asan/TestCases/asan_update_allocation.cpp
blob: d703fe024aa054431f40784ce26cbfbd1ff82cd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// RUN: %clangxx_asan -O0 -DSIZE=10 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
// RUN: %clangxx_asan -O0 -DSIZE=10000000 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
// REQUIRES: stable-runtime

#include <stdlib.h>
#include <sanitizer/asan_interface.h>

void UPDATE(void *p) {
  __asan_update_allocation_context(p);
}

int main() {
  char *x = (char*)malloc(SIZE * sizeof(char));
  UPDATE(x);
  free(x);
  return x[5];
  // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
  // CHECK: UPDATE
}
OpenPOWER on IntegriCloud