Coverage Report

Created: 2026-02-10 07:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poppler/qt6/tests/fuzzing/qt_annot_fuzzer.cc
Line
Count
Source
1
#include <cstdint>
2
#include <poppler-qt6.h>
3
#include <QtCore/QBuffer>
4
5
static void dummy_error_function(const QString &message, const QVariant &closure)
6
0
{
7
0
    Q_UNUSED(message)
8
0
    Q_UNUSED(closure)
9
0
}
10
11
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
12
65.0k
{
13
65.0k
    Poppler::setDebugErrorFunction(dummy_error_function, QVariant());
14
65.0k
    const QFont font(QStringLiteral("Helvetica"), 20);
15
65.0k
    const QColor color = QColor::fromRgb(0xAB, 0xCD, 0xEF);
16
17
65.0k
    QByteArray in_data = QByteArray::fromRawData((const char *)data, size);
18
65.0k
    std::unique_ptr<Poppler::Document> doc = Poppler::Document::loadFromData(in_data);
19
20
65.0k
    if (!doc || doc->isLocked()) {
21
10.4k
        return 0;
22
10.4k
    }
23
24
453k
    for (int i = 0; i < doc->numPages(); i++) {
25
398k
        std::unique_ptr<Poppler::Page> p = doc->page(i);
26
398k
        if (!p) {
27
277k
            continue;
28
277k
        }
29
121k
        Poppler::TextAnnotation *ann = new Poppler::TextAnnotation(Poppler::TextAnnotation::InPlace);
30
121k
        ann->setTextFont(font);
31
121k
        ann->setTextColor(color);
32
121k
        ann->setBoundary(QRectF(0.1, 0.1, 0.2, 0.2));
33
121k
        ann->setContents(QString::fromUtf8(in_data));
34
121k
        p->addAnnotation(ann);
35
36
121k
        QBuffer buffer;
37
121k
        buffer.open(QIODevice::WriteOnly);
38
121k
        std::unique_ptr<Poppler::PDFConverter> conv(doc->pdfConverter());
39
121k
        conv->setOutputDevice(&buffer);
40
121k
        conv->setPDFOptions(Poppler::PDFConverter::WithChanges);
41
121k
        conv->convert();
42
121k
        buffer.close();
43
121k
        delete ann;
44
121k
    }
45
46
54.5k
    return 0;
47
65.0k
}