summaryrefslogtreecommitdiff
path: root/test/msan/c-strdup.c
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-01-07 19:55:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-01-07 19:55:37 +0000
commitca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (patch)
tree9b19e801150082c33e9152275829a6ce90614b55 /test/msan/c-strdup.c
parent8ef50bf3d1c287b5013c3168de77a462dfce3495 (diff)
Diffstat (limited to 'test/msan/c-strdup.c')
-rw-r--r--test/msan/c-strdup.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/msan/c-strdup.c b/test/msan/c-strdup.c
new file mode 100644
index 0000000000000..059300e4205ab
--- /dev/null
+++ b/test/msan/c-strdup.c
@@ -0,0 +1,17 @@
+// RUN: %clang_msan -m64 -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clang_msan -m64 -O1 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clang_msan -m64 -O2 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clang_msan -m64 -O3 %s -o %t && %run %t >%t.out 2>&1
+
+// Test that strdup in C programs is intercepted.
+// GLibC headers translate strdup to __strdup at -O1 and higher.
+
+#include <stdlib.h>
+#include <string.h>
+int main(int argc, char **argv) {
+ char buf[] = "abc";
+ char *p = strdup(buf);
+ if (*p)
+ exit(0);
+ return 0;
+}