summaryrefslogtreecommitdiff
path: root/Meta/Lagom/Fuzzers/FuzzPDF.cpp
blob: b2eb5e701f73e50905a3b0dda4e211a89858d8ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Copyright (c) 2021, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibPDF/Document.h>
#include <stdint.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
    ReadonlyBytes bytes { data, size };

    if (auto maybe_document = PDF::Document::create(bytes); !maybe_document.is_error()) {
        auto document = maybe_document.release_value();
        auto pages = document->get_page_count();
        for (size_t i = 0; i < pages; ++i) {
            (void)document->get_page(i);
        }
    }

    return 0;
}