aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Fuzzer/test/LeakTimeoutTest.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-03-24 01:32:08 +0000
committerKostya Serebryany <kcc@google.com>2016-03-24 01:32:08 +0000
commit315167339eb5f146040033b555c00ee0671ac72a (patch)
tree3c8c21c4fb43ce69032d958a41261c4afd5413c8 /llvm/lib/Fuzzer/test/LeakTimeoutTest.cpp
parent37df19ebee81322aa018af65cae57eafde6c5350 (diff)
downloadllvm-315167339eb5f146040033b555c00ee0671ac72a.zip
llvm-315167339eb5f146040033b555c00ee0671ac72a.tar.gz
llvm-315167339eb5f146040033b555c00ee0671ac72a.tar.bz2
[libFuzzer] don't report memory leaks if we are dying due to a timeout (just use _Exit instead of exit in the timeout callback)
llvm-svn: 264237
Diffstat (limited to 'llvm/lib/Fuzzer/test/LeakTimeoutTest.cpp')
-rw-r--r--llvm/lib/Fuzzer/test/LeakTimeoutTest.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/LeakTimeoutTest.cpp b/llvm/lib/Fuzzer/test/LeakTimeoutTest.cpp
new file mode 100644
index 0000000..3aa56c4
--- /dev/null
+++ b/llvm/lib/Fuzzer/test/LeakTimeoutTest.cpp
@@ -0,0 +1,14 @@
+// Test with a leak.
+#include <cstdint>
+#include <cstddef>
+
+static volatile int *Sink;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (!Size) return 0;
+ Sink = new int;
+ Sink = new int;
+ while (Sink) *Sink = 0; // Infinite loop.
+ return 0;
+}
+