summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/time_interceptor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/asan/TestCases/time_interceptor.cc')
-rw-r--r--test/asan/TestCases/time_interceptor.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/asan/TestCases/time_interceptor.cc b/test/asan/TestCases/time_interceptor.cc
new file mode 100644
index 000000000000..89b2183bcde2
--- /dev/null
+++ b/test/asan/TestCases/time_interceptor.cc
@@ -0,0 +1,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: win32
+
+#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;
+}