8
8
#include < vector>
9
9
10
10
#include < fmt/chrono.h>
11
+ #include " fuzzer_common.h"
11
12
12
13
template <typename Item>
13
14
void invoke_fmt (const uint8_t * Data, std::size_t Size ) {
@@ -24,17 +25,16 @@ void invoke_fmt(const uint8_t* Data, std::size_t Size) {
24
25
Data += N;
25
26
Size -= N;
26
27
27
- #define SEPARATE_ALLOCATION 0
28
- #if SEPARATE_ALLOCATION
28
+ #if FMT_FUZZ_SEPARATE_ALLOCATION
29
29
// allocates as tight as possible, making it easier to catch buffer overruns.
30
30
std::vector<char > fmtstringbuffer (Size );
31
31
std::memcpy (fmtstringbuffer.data (), Data, Size );
32
32
auto fmtstring = fmt::string_view (fmtstringbuffer.data (), Size );
33
33
#else
34
34
auto fmtstring = fmt::string_view ((const char *)Data, Size );
35
35
#endif
36
- # define ALLOCATE_RESULT_IN_STRING 0
37
- #if ALLOCATE_RESULT_IN_STRING
36
+
37
+ #if FMT_FUZZ_FORMAT_TO_STRING
38
38
std::string message = fmt::format (fmtstring, item);
39
39
#else
40
40
fmt::memory_buffer message;
@@ -52,7 +52,7 @@ void invoke_fmt_time(const uint8_t* Data, std::size_t Size) {
52
52
std::memcpy (&item, Data, N);
53
53
Data += N;
54
54
Size -= N;
55
- #if SEPARATE_ALLOCATION
55
+ #if FMT_FUZZ_SEPARATE_ALLOCATION
56
56
// allocates as tight as possible, making it easier to catch buffer overruns.
57
57
std::vector<char > fmtstringbuffer (Size );
58
58
std::memcpy (fmtstringbuffer.data (), Data, Size );
@@ -62,7 +62,7 @@ void invoke_fmt_time(const uint8_t* Data, std::size_t Size) {
62
62
#endif
63
63
auto * b = std::localtime (&item);
64
64
if (b) {
65
- #if ALLOCATE_RESULT_IN_STRING
65
+ #if FMT_FUZZ_FORMAT_TO_STRING
66
66
std::string message = fmt::format (fmtstring, *b);
67
67
#else
68
68
fmt::memory_buffer message;
0 commit comments