[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:
Kostya Serebryany 2016-02-04 00:02:17 +00:00
parent 2432bd0ddd
commit b92602ada0
4 changed files with 16 additions and 0 deletions

View File

@ -75,6 +75,7 @@ void Fuzzer::StaticDeathCallback() {
}
void Fuzzer::DeathCallback() {
if (!CurrentUnitSize) return;
Printf("DEATH:\n");
if (CurrentUnitSize <= kMaxUnitSizeToPrint) {
PrintHexArray(CurrentUnitData, CurrentUnitSize, "\n");

View File

@ -20,6 +20,7 @@ set(Tests
FullCoverageSetTest
InitializeTest
MemcmpTest
LeakTest
NullDerefTest
RepeatedMemcmp
SimpleCmpTest

View File

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

View File

@ -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: