diff options
| author | Kostya Serebryany <kcc@google.com> | 2019-02-08 01:20:54 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2019-02-08 01:20:54 +0000 |
| commit | 0719b3527f5bc550d3677161ca49a0e6d462c9e1 (patch) | |
| tree | 1d7883291a5e176f48a2366581f5ef0112dfbcb0 /compiler-rt/lib/fuzzer/FuzzerMutate.cpp | |
| parent | 3189d5f48cae13f02a14a894f631dd5c23b0aeae (diff) | |
| download | bcm5719-llvm-0719b3527f5bc550d3677161ca49a0e6d462c9e1.tar.gz bcm5719-llvm-0719b3527f5bc550d3677161ca49a0e6d462c9e1.zip | |
[libFuzzer] refactor the way we choose the element to cross-over with, NFC (expected1); add a flag -seed_inputs= to pass extra seed inputs as file paths, not dirs
llvm-svn: 353494
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerMutate.cpp')
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerMutate.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp index 6dc2eccdbb3..92e469f4c14 100644 --- a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp @@ -8,12 +8,12 @@ // Mutate a test input. //===----------------------------------------------------------------------===// -#include "FuzzerMutate.h" -#include "FuzzerCorpus.h" #include "FuzzerDefs.h" #include "FuzzerExtFunctions.h" #include "FuzzerIO.h" +#include "FuzzerMutate.h" #include "FuzzerOptions.h" +#include "FuzzerTracePC.h" namespace fuzzer { @@ -72,10 +72,10 @@ size_t MutationDispatcher::Mutate_Custom(uint8_t *Data, size_t Size, size_t MutationDispatcher::Mutate_CustomCrossOver(uint8_t *Data, size_t Size, size_t MaxSize) { - if (!Corpus || Corpus->size() < 2 || Size == 0) + if (Size == 0) return 0; - size_t Idx = Rand(Corpus->size()); - const Unit &Other = (*Corpus)[Idx]; + if (!CrossOverWith) return 0; + const Unit &Other = *CrossOverWith; if (Other.empty()) return 0; CustomCrossOverInPlaceHere.resize(MaxSize); @@ -421,9 +421,9 @@ size_t MutationDispatcher::Mutate_ChangeBinaryInteger(uint8_t *Data, size_t MutationDispatcher::Mutate_CrossOver(uint8_t *Data, size_t Size, size_t MaxSize) { if (Size > MaxSize) return 0; - if (!Corpus || Corpus->size() < 2 || Size == 0) return 0; - size_t Idx = Rand(Corpus->size()); - const Unit &O = (*Corpus)[Idx]; + if (Size == 0) return 0; + if (!CrossOverWith) return 0; + const Unit &O = *CrossOverWith; if (O.empty()) return 0; MutateInPlaceHere.resize(MaxSize); auto &U = MutateInPlaceHere; |

