2014-05-01 05:34:17 +08:00
|
|
|
// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
|
2013-04-10 23:13:00 +08:00
|
|
|
|
2013-05-17 23:11:26 +08:00
|
|
|
// Test the time() interceptor.
|
2013-04-10 23:13:00 +08:00
|
|
|
|
2014-05-28 21:06:14 +08:00
|
|
|
// There's no interceptor for time() on Windows yet.
|
|
|
|
// XFAIL: win32
|
|
|
|
|
2013-04-10 23:13:00 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
time_t *tm = (time_t*)malloc(sizeof(time_t));
|
|
|
|
free(tm);
|
2013-05-17 23:11:26 +08:00
|
|
|
time_t t = time(tm);
|
2013-04-11 19:29:07 +08:00
|
|
|
printf("Time: %s\n", ctime(&t)); // NOLINT
|
2013-04-10 23:13:00 +08:00
|
|
|
// CHECK: use-after-free
|
2014-06-18 17:27:40 +08:00
|
|
|
// Regression check for
|
|
|
|
// https://code.google.com/p/address-sanitizer/issues/detail?id=321
|
|
|
|
// CHECK: SUMMARY
|
2013-04-10 23:13:00 +08:00
|
|
|
return 0;
|
|
|
|
}
|