diff options
| author | Max Moroz <mmoroz@chromium.org> | 2017-09-12 02:01:54 +0000 |
|---|---|---|
| committer | Max Moroz <mmoroz@chromium.org> | 2017-09-12 02:01:54 +0000 |
| commit | 3f26dac416482ce224d182f1d22b6872f01b3ccf (patch) | |
| tree | e0d3f6b36fa2976c42a62f14e1e4de4a6d4c46be /compiler-rt/lib/fuzzer | |
| parent | d56b90fb4c637cef59f64bd18ea2710fb861427b (diff) | |
| download | bcm5719-llvm-3f26dac416482ce224d182f1d22b6872f01b3ccf.tar.gz bcm5719-llvm-3f26dac416482ce224d182f1d22b6872f01b3ccf.zip | |
[libfuzzer] Compare TotalNumberOfRuns with MaxNumberOfRuns when testing 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: https://github.com/google/oss-fuzz/issues/822#issuecomment-328153970
Reviewers: kcc
Reviewed By: kcc
Differential Revision: https://reviews.llvm.org/D37632
llvm-svn: 312993
Diffstat (limited to 'compiler-rt/lib/fuzzer')
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerLoop.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp index 0354fc86e0c..d6185fdee8f 100644 --- a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp @@ -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. |

