Kostya Serebryany | 8b8f7a3 | 2016-05-06 23:38:07 +0000 | [diff] [blame] | 1 | // 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> |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 6 | #include <cstddef> |
Kostya Serebryany | 8b8f7a3 | 2016-05-06 23:38:07 +0000 | [diff] [blame] | 7 | #include <cstdint> |
| 8 | #include <cstdlib> |
Kostya Serebryany | 8b8f7a3 | 2016-05-06 23:38:07 +0000 | [diff] [blame] | 9 | #include <cstring> |
| 10 | #include <iostream> |
Marcos Pividori | 6a7e4c2 | 2016-12-16 17:35:13 +0000 | [diff] [blame] | 11 | #include <thread> |
Kostya Serebryany | 8b8f7a3 | 2016-05-06 23:38:07 +0000 | [diff] [blame] | 12 | |
| 13 | static volatile char *SinkPtr; |
| 14 | |
| 15 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 16 | if (Size > 0 && Data[0] == 'H') { |
| 17 | if (Size > 1 && Data[1] == 'i') { |
| 18 | if (Size > 2 && Data[2] == '!') { |
| 19 | while (true) { |
| 20 | size_t kSize = 1 << 28; |
| 21 | char *p = new char[kSize]; |
| 22 | memset(p, 0, kSize); |
| 23 | SinkPtr = p; |
Marcos Pividori | 6a7e4c2 | 2016-12-16 17:35:13 +0000 | [diff] [blame] | 24 | std::this_thread::sleep_for(std::chrono::seconds(1)); |
Kostya Serebryany | 8b8f7a3 | 2016-05-06 23:38:07 +0000 | [diff] [blame] | 25 | } |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | return 0; |
| 30 | } |
| 31 | |