summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/time_interceptor.cpp
blob: f78af1056af672a5b8247d78bd1127cfd7e42a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s

// Test the time() interceptor.

// There's no interceptor for time() on Windows yet.
// XFAIL: windows-msvc

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
  time_t *tm = (time_t*)malloc(sizeof(time_t));
  free(tm);
  time_t t = time(tm);
  printf("Time: %s\n", ctime(&t));  // NOLINT
  // CHECK: use-after-free
  // Regression check for
  // https://code.google.com/p/address-sanitizer/issues/detail?id=321
  // CHECK: SUMMARY
  return 0;
}