OSDN Git Service

[libFuzzer] don't create large random mutations when given an empty seed
authorKostya Serebryany <kcc@google.com>
Tue, 27 Dec 2016 22:15:04 +0000 (22:15 +0000)
committerKostya Serebryany <kcc@google.com>
Tue, 27 Dec 2016 22:15:04 +0000 (22:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290634 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerMutate.cpp

index 80b7a5f..96a87b8 100644 (file)
@@ -486,7 +486,7 @@ size_t MutationDispatcher::MutateImpl(uint8_t *Data, size_t Size,
                                       const std::vector<Mutator> &Mutators) {
   assert(MaxSize > 0);
   if (Size == 0) {
-    for (size_t i = 0; i < MaxSize; i++)
+    for (size_t i = 0; i < Min(size_t(4), MaxSize); i++)
       Data[i] = RandCh(Rand);
     if (Options.OnlyASCII)
       ToASCII(Data, MaxSize);