1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03, c++11 |
10 | |
11 | #include <algorithm> |
12 | #include <cstddef> |
13 | #include <cstdint> |
14 | #include <vector> |
15 | |
16 | #include "fuzz.h" |
17 | |
18 | extern "C"int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { |
19 | if (size < 2) |
20 | return 0; |
21 | std::vector<std::uint8_t> working(data, data + size); |
22 | std::make_heap(first: working.begin(), last: working.end()); |
23 | |
24 | // Pop things off, one at a time |
25 | auto iter = --working.end(); |
26 | while (iter != working.begin()) { |
27 | std::pop_heap(first: working.begin(), last: iter); |
28 | if (!std::is_heap(first: working.begin(), last: --iter)) |
29 | return 2; |
30 | } |
31 | |
32 | return 0; |
33 | } |
34 |