[llvm] r292520 - [libFuzzer] ensure that entries in PersistentAutoDictionary are not empty

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 13:14:48 PST 2017


Author: kcc
Date: Thu Jan 19 15:14:47 2017
New Revision: 292520

URL: http://llvm.org/viewvc/llvm-project?rev=292520&view=rev
Log:
[libFuzzer] ensure that entries in PersistentAutoDictionary are not empty

Modified:
    llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp

Modified: llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp?rev=292520&r1=292519&r2=292520&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp Thu Jan 19 15:14:47 2017
@@ -272,6 +272,7 @@ size_t MutationDispatcher::Mutate_AddWor
   default:
     assert(0);
   }
+  if (!DE.GetW().size()) return 0;
   Size = ApplyDictionaryEntry(Data, Size, MaxSize, DE);
   if (!Size) return 0;
   DictionaryEntry &DERef =
@@ -462,6 +463,7 @@ void MutationDispatcher::RecordSuccessfu
   for (auto DE : CurrentDictionaryEntrySequence) {
     // PersistentAutoDictionary.AddWithSuccessCountOne(DE);
     DE->IncSuccessCount();
+    assert(DE->GetW().size());
     // Linear search is fine here as this happens seldom.
     if (!PersistentAutoDictionary.ContainsWord(DE->GetW()))
       PersistentAutoDictionary.push_back({DE->GetW(), 1});
@@ -476,6 +478,7 @@ void MutationDispatcher::PrintRecommende
   if (V.empty()) return;
   Printf("###### Recommended dictionary. ######\n");
   for (auto &DE: V) {
+    assert(DE.GetW().size());
     Printf("\"");
     PrintASCII(DE.GetW(), "\"");
     Printf(" # Uses: %zd\n", DE.GetUseCount());




More information about the llvm-commits mailing list