/src/serenity/Meta/Lagom/Fuzzers/FuzzPDF.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2021, the SerenityOS developers. |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibPDF/Document.h> |
8 | | #include <stdint.h> |
9 | | |
10 | | extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) |
11 | 14 | { |
12 | 14 | AK::set_debug_enabled(false); |
13 | | |
14 | 14 | ReadonlyBytes bytes { data, size }; |
15 | | |
16 | 14 | if (auto maybe_document = PDF::Document::create(bytes); !maybe_document.is_error()) { |
17 | 0 | auto document = maybe_document.release_value(); |
18 | 0 | (void)document->initialize(); |
19 | 0 | auto pages = document->get_page_count(); |
20 | 0 | for (size_t i = 0; i < pages; ++i) { |
21 | 0 | (void)document->get_page(i); |
22 | 0 | } |
23 | 0 | } |
24 | | |
25 | 14 | return 0; |
26 | 14 | } |