• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file is distributed under the University of Illinois Open Source
2 // License. See LICENSE.TXT for details.
3 
4 // Threaded test for a fuzzer. The fuzzer should not crash.
5 #include <assert.h>
6 #include <cstdint>
7 #include <cstddef>
8 #include <cstring>
9 #include <thread>
10 
LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
12   if (Size < 8) return 0;
13   assert(Data);
14   auto C = [&] {
15     size_t Res = 0;
16     for (size_t i = 0; i < Size / 2; i++)
17       Res += memcmp(Data, Data + Size / 2, 4);
18     return Res;
19   };
20   std::thread T[] = {std::thread(C), std::thread(C), std::thread(C),
21                      std::thread(C), std::thread(C), std::thread(C)};
22   for (auto &X : T)
23     X.join();
24   return 0;
25 }
26 
27