llvm-project/compiler-rt/test/fuzzer/UseAfterDtor.cpp
Matt Morehouse a34c65e845 [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

llvm-svn: 336619
2018-07-09 23:51:08 +00:00

28 lines
483 B
C++

#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;
}