Coverage Report

Created: 2025-08-24 07:07

/src/glaze/fuzzing/json_prettify.cpp
Line
Count
Source
1
#include <cstddef>
2
#include <cstdint>
3
#include <glaze/glaze.hpp>
4
#include <vector>
5
6
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size)
7
1.32k
{
8
   // use a vector with null termination instead of a std::string to avoid
9
   // small string optimization to hide bounds problems
10
1.32k
   std::vector<char> buffer{Data, Data + Size};
11
12
   // non-null terminated
13
1.32k
   {
14
1.32k
      const auto& input = buffer;
15
1.32k
      [[maybe_unused]] auto beautiful = glz::prettify_json(input);
16
1.32k
   }
17
18
   // null terminated
19
1.32k
   {
20
1.32k
      buffer.push_back('\0');
21
1.32k
      const auto& input = buffer;
22
1.32k
      [[maybe_unused]] auto beautiful = glz::prettify_json(input);
23
1.32k
   }
24
25
1.32k
   return 0;
26
1.32k
}