forked from OSchip/llvm-project
[libFuzzer] don't write the test unit when a leak is detected (since we don't know which unit causes the leak)
llvm-svn: 259731
This commit is contained in:
parent
2432bd0ddd
commit
b92602ada0
|
@ -75,6 +75,7 @@ void Fuzzer::StaticDeathCallback() {
|
|||
}
|
||||
|
||||
void Fuzzer::DeathCallback() {
|
||||
if (!CurrentUnitSize) return;
|
||||
Printf("DEATH:\n");
|
||||
if (CurrentUnitSize <= kMaxUnitSizeToPrint) {
|
||||
PrintHexArray(CurrentUnitData, CurrentUnitSize, "\n");
|
||||
|
|
|
@ -20,6 +20,7 @@ set(Tests
|
|||
FullCoverageSetTest
|
||||
InitializeTest
|
||||
MemcmpTest
|
||||
LeakTest
|
||||
NullDerefTest
|
||||
RepeatedMemcmp
|
||||
SimpleCmpTest
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// Test with a leak.
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
static volatile void *Sink;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
Sink = new int;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -57,3 +57,6 @@ SINGLE_INPUTS: LLVMFuzzer-SimpleTest: Running 2 inputs.
|
|||
SINGLE_INPUTS: aaa:
|
||||
SINGLE_INPUTS: bbb:
|
||||
|
||||
RUN: LLVMFuzzer-LeakTest -runs=10 2>&1 | FileCheck %s --check-prefix=LEAK
|
||||
LEAK: ERROR: LeakSanitizer: detected memory leaks
|
||||
LEAK-NOT: DEATH:
|
||||
|
|
Loading…
Reference in New Issue