blob: 18949c7c8c9865881e417791106300a492d37ca3 [file] [log] [blame]
Kostya Serebryany8b8f7a32016-05-06 23:38:07 +00001// This file is distributed under the University of Illinois Open Source
2// License. See LICENSE.TXT for details.
3
4// Tests OOM handling.
5#include <assert.h>
6#include <cstdint>
7#include <cstdlib>
8#include <cstddef>
9#include <cstring>
10#include <iostream>
Marcos Pividori6a7e4c22016-12-16 17:35:13 +000011#include <thread>
Kostya Serebryany8b8f7a32016-05-06 23:38:07 +000012#include <unistd.h>
13
14static volatile char *SinkPtr;
15
16extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
17 if (Size > 0 && Data[0] == 'H') {
18 if (Size > 1 && Data[1] == 'i') {
19 if (Size > 2 && Data[2] == '!') {
20 while (true) {
21 size_t kSize = 1 << 28;
22 char *p = new char[kSize];
23 memset(p, 0, kSize);
24 SinkPtr = p;
Marcos Pividori6a7e4c22016-12-16 17:35:13 +000025 std::this_thread::sleep_for(std::chrono::seconds(1));
Kostya Serebryany8b8f7a32016-05-06 23:38:07 +000026 }
27 }
28 }
29 }
30 return 0;
31}
32