summaryrefslogtreecommitdiff
path: root/Meta/Lagom/Fuzzers/FuzzPDF.cpp
blob: 733fcb7e5c7dddcbab04986533dd6ea44494aacd (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 };
    auto doc = PDF::Document::create(bytes);

    if (doc) {
        auto pages = doc->get_page_count();
        for (size_t i = 0; i < pages; ++i) {
            (void)doc->get_page(i);
        }
    }

    return 0;
}