[PATCH] D30683: [libFuzzer] Use ChooseUnitIdxToMutate to pick item for crossover.

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 14:11:41 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL297891: [libFuzzer] Use ChooseUnitIdxToMutate to pick item for crossover. (authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D30683?vs=90813&id=91934#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30683

Files:
  llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp
  llvm/trunk/lib/Fuzzer/FuzzerMutate.h


Index: llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp
===================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp
+++ llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp
@@ -77,7 +77,7 @@
                                                   size_t MaxSize) {
   if (!Corpus || Corpus->size() < 2 || Size == 0)
     return 0;
-  size_t Idx = Rand(Corpus->size());
+  size_t Idx = Corpus->ChooseUnitIdxToMutate(Rand);
   const Unit &Other = (*Corpus)[Idx];
   if (Other.empty())
     return 0;
Index: llvm/trunk/lib/Fuzzer/FuzzerMutate.h
===================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerMutate.h
+++ llvm/trunk/lib/Fuzzer/FuzzerMutate.h
@@ -88,7 +88,7 @@
   void ClearAutoDictionary();
   void PrintRecommendedDictionary();
 
-  void SetCorpus(const InputCorpus *Corpus) { this->Corpus = Corpus; }
+  void SetCorpus(InputCorpus *Corpus) { this->Corpus = Corpus; }
 
   Random &GetRand() { return Rand; }
 
@@ -141,7 +141,7 @@
   DictionaryEntry CmpDictionaryEntriesDeque[kCmpDictionaryEntriesDequeSize];
   size_t CmpDictionaryEntriesDequeIdx = 0;
 
-  const InputCorpus *Corpus = nullptr;
+  InputCorpus *Corpus = nullptr;
   std::vector<uint8_t> MutateInPlaceHere;
   // CustomCrossOver needs its own buffer as a custom implementation may call
   // LLVMFuzzerMutate, which in turn may resize MutateInPlaceHere.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30683.91934.patch
Type: text/x-patch
Size: 1391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170315/dfbd3f05/attachment.bin>


More information about the llvm-commits mailing list