]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/asan/TestCases/time_interceptor.cc
Vendor import of compiler-rt trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / asan / TestCases / time_interceptor.cc
1 // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
2
3 // Test the time() interceptor.
4
5 // There's no interceptor for time() on Windows yet.
6 // XFAIL: windows-msvc
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <time.h>
11
12 int main() {
13   time_t *tm = (time_t*)malloc(sizeof(time_t));
14   free(tm);
15   time_t t = time(tm);
16   printf("Time: %s\n", ctime(&t));  // NOLINT
17   // CHECK: use-after-free
18   // Regression check for
19   // https://code.google.com/p/address-sanitizer/issues/detail?id=321
20   // CHECK: SUMMARY
21   return 0;
22 }