blob: b5ad0813e3d555baa955180cc496d84ba2a69044 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <util/generic/vector.h>
#include <util/stream/mem.h>
template <class T>
static inline T Read(IInputStream& in) {
T t;
in.LoadOrFail(&t, sizeof(t));
return t;
}
extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) {
TMemoryInput mi(data, size);
try {
TVector<ui16> v;
while (mi.Avail()) {
char cmd = Read<char>(mi);
switch (cmd % 2) {
case 0: {
const size_t cnt = 1 + Read<ui8>(mi) % 16;
for (size_t i = 0; i < cnt; ++i) {
v.push_back(i);
}
break;
}
case 1: {
if (v) {
v.pop_back();
}
break;
}
}
}
} catch (...) {
// ¯\_(ツ)_/¯
}
return 0; // Non-zero return values are reserved for future use.
}
|