blob: 1957c1f90fc31a9e99966ad545746a6968c8325d [file] [log] [blame]
George Karpenkov10ab2ac2017-08-21 23:25:50 +00001// This file is distributed under the University of Illinois Open Source
2// License. See LICENSE.TXT for details.
3
4// Test that we can find the minimal item in the corpus (3 bytes: "FUZ").
5#include <cstddef>
6#include <cstdint>
7#include <cstdio>
8#include <cstdlib>
9#include <cstring>
10
11static volatile int Sink;
12
13void Foo() {
14 Sink++;
15}
16
17extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
18 int8_t Ids[256];
19 memset(Ids, -1, sizeof(Ids));
20 for (size_t i = 0; i < Size; i++)
21 if (Ids[Data[i]] == -1)
22 Ids[Data[i]] = i;
23 int F = Ids[(unsigned char)'F'];
24 int U = Ids[(unsigned char)'U'];
25 int Z = Ids[(unsigned char)'Z'];
26 if (F >= 0 && U > F && Z > U) {
27 Foo();
28 }
29 return 0;
30}
31