Skip to content

Commit

Permalink
[libfuzzer] Compare TotalNumberOfRuns with MaxNumberOfRuns when testi…
Browse files Browse the repository at this point in the history
…ng a memory leak.

Summary:
Fuzzer::TryDetectingAMemoryLeak may call ExecuteCallback which would
increment TotalNumberOfRuns, but it doesn't respect Options.MaxNumberOfRuns
value specified by a user.

Context: google/oss-fuzz#822 (comment)

Reviewers: kcc

Reviewed By: kcc

Differential Revision: https://reviews.llvm.org/D37632

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312993 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Dor1s committed Sep 12, 2017
1 parent a139c09 commit 0d383d4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions FuzzerLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ void Fuzzer::TryDetectingAMemoryLeak(const uint8_t *Data, size_t Size,
bool DuringInitialCorpusExecution) {
if (!HasMoreMallocsThanFrees) return; // mallocs==frees, a leak is unlikely.
if (!Options.DetectLeaks) return;
if (!DuringInitialCorpusExecution &&
TotalNumberOfRuns >= Options.MaxNumberOfRuns) return;
if (!&(EF->__lsan_enable) || !&(EF->__lsan_disable) ||
!(EF->__lsan_do_recoverable_leak_check))
return; // No lsan.
Expand Down

0 comments on commit 0d383d4

Please sign in to comment.