aboutsummaryrefslogtreecommitdiff
path: root/test/sanitizer_common/TestCases/Posix/fgets.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/sanitizer_common/TestCases/Posix/fgets.cc')
-rw-r--r--test/sanitizer_common/TestCases/Posix/fgets.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/Posix/fgets.cc b/test/sanitizer_common/TestCases/Posix/fgets.cc
new file mode 100644
index 000000000000..8dde5cd1a84f
--- /dev/null
+++ b/test/sanitizer_common/TestCases/Posix/fgets.cc
@@ -0,0 +1,20 @@
+// RUN: %clangxx -g %s -o %t && %run %t
+
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ FILE *fp;
+ char buf[2];
+ char *s;
+
+ fp = fopen(argv[0], "r");
+ if (!fp)
+ return 1;
+
+ s = fgets(buf, sizeof(buf), fp);
+ if (!s)
+ return 2;
+
+ fclose(fp);
+ return 0;
+}