diff options
author | Matt Morehouse <mascasa@google.com> | 2018-07-09 23:51:08 +0000 |
---|---|---|
committer | Matt Morehouse <mascasa@google.com> | 2018-07-09 23:51:08 +0000 |
commit | 7187f19d355615e6781dfaeb7bf5df277ed68a1c (patch) | |
tree | b9549a6e853a9da3af9dd9d620d36a60282d22ec /test/fuzzer/UseAfterDtor.cpp | |
parent | ae08c0939626aef3878b70c5ec8762dbf98b3e37 (diff) |
[libFuzzer] Make -fsanitize=memory,fuzzer work.
This patch allows libFuzzer to fuzz applications instrumented with MSan
without recompiling libFuzzer with MSan instrumentation.
Fixes https://github.com/google/sanitizers/issues/958.
Differential Revision: https://reviews.llvm.org/D48891
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336619 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/fuzzer/UseAfterDtor.cpp')
-rw-r--r-- | test/fuzzer/UseAfterDtor.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/fuzzer/UseAfterDtor.cpp b/test/fuzzer/UseAfterDtor.cpp new file mode 100644 index 000000000..dcefca5cc --- /dev/null +++ b/test/fuzzer/UseAfterDtor.cpp @@ -0,0 +1,27 @@ +#include <cstdint> +#include <cstdio> + +struct Simple { + int x_; + Simple() { + x_ = 5; + } + ~Simple() { + x_ += 1; + } +}; + +Simple *volatile SimpleSink; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + if (Size < 4) return 0; + if (Data[0] == 'F' && Data[1] == 'U' && Data[2] == 'Z' && Data[3] == 'Z') { + { + Simple S; + SimpleSink = &S; + } + if (SimpleSink->x_) fprintf(stderr, "Failed to catch use-after-dtor\n"); + } + return 0; +} + |