Coverage Report

Created: 2025-10-10 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/crow/tests/fuzz/template_fuzzer.cpp
Line
Count
Source
1
#include <cstdint>
2
#include <fuzzer/FuzzedDataProvider.h>
3
4
#include "crow.h"
5
6
static crow::mustache::context build_context_object(FuzzedDataProvider &fdp)
7
4.13k
{
8
4.13k
    crow::mustache::context ctx{};
9
10
7.34k
    for (auto i = 0; i < fdp.ConsumeIntegralInRange(0, 10); ++i)
11
3.21k
    {
12
3.21k
        ctx[fdp.ConsumeRandomLengthString()] = fdp.ConsumeRandomLengthString();
13
3.21k
    }
14
15
4.13k
    return ctx;
16
4.13k
}
17
18
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, const std::size_t size)
19
5.00k
{
20
5.00k
    FuzzedDataProvider fdp{data, size};
21
5.00k
    try
22
5.00k
    {
23
5.00k
        auto page = crow::mustache::compile(fdp.ConsumeRandomLengthString());
24
5.00k
        auto ctx = build_context_object(fdp);
25
5.00k
        page.render_string(ctx);
26
5.00k
    }
27
5.00k
    catch (const std::exception& e)
28
5.00k
    {
29
        // No special handling for invalid inputs or rendering errors
30
941
    }
31
32
5.00k
    return 0;
33
5.00k
}