Skip to content

Commit c24fd02

Browse files
committed
use boost::variant2::variant instead of std
1 parent 21131ce commit c24fd02

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

.github/workflows/run_fuzzer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
buildtype: 'boost'
6161
path: 'head'
6262
toolset: clang-18
63-
cxxstd: 14
63+
cxxstd: 17
6464
targets: libs/json/fuzzing//run
6565
- name: Pack the corpus
6666
working-directory: boost-root/libs/json/fuzzing/

fuzzing/fuzz_direct_parse.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@
77
//
88

99
#include <boost/json/parse_into.hpp>
10+
#include <boost/variant2/variant.hpp>
1011
#include <boost/describe.hpp>
1112
#include <map>
1213

13-
#ifndef BOOST_NO_CXX17_HDR_VARIANT
14-
# include <variant>
15-
# define IF_CXX17_HDR_VARIANT(...) __VA_ARGS__
16-
#else
17-
# define IF_CXX17_HDR_VARIANT(...)
18-
#endif // BOOST_NO_CXX17_HDR_VARIANT
19-
2014
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
2115
# include <optional>
2216
# define IF_CXX17_HDR_OPTIONAL(...) __VA_ARGS__
@@ -46,10 +40,7 @@ struct Object
4640
std::tuple<bool, std::uint64_t, std::int64_t, double, std::string> t1;
4741
std::tuple<std::array<std::string, 3>, std::array<double, 3>, std::nullptr_t> t2;
4842
std::tuple<std::vector<std::string>, std::vector<double>> t3;
49-
50-
#ifndef BOOST_NO_CXX17_HDR_VARIANT
51-
std::variant<bool, std::uint64_t, std::int64_t, double, std::string> v;
52-
#endif // BOOST_NO_CXX17_HDR_VARIANT
43+
boost::variant2::variant<bool, std::uint64_t, std::int64_t, double, std::string> v;
5344

5445
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
5546
std::optional<bool> ob;
@@ -61,8 +52,9 @@ struct Object
6152
};
6253

6354
BOOST_DESCRIBE_STRUCT(Object, (),
64-
(b, i64, u64, f, d, s, v1, v2, v3, a1, a2, a3, m1, m2, m3, t1, t2, t3,
65-
IF_CXX17_HDR_OPTIONAL(ob, oi, ou, od, os), IF_CXX17_HDR_OPTIONAL(v)))
55+
(b, i64, u64, f, d, s, v1, v2, v3, a1, a2, a3, m1, m2, m3, t1, t2, t3, v,
56+
IF_CXX17_HDR_OPTIONAL(ob, oi, ou, od, os)))
57+
6658

6759
bool
6860
fuzz_direct_parse(string_view sv)

fuzzing/old_crashes/direct_parse/valid_cxx14.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"m3": {"k": 0.42},
1717
"t1": [true, 1, 2, 1.23, "s"],
1818
"t2": [["a", "b", "c"], [1.0, 0.1, 2.2], null],
19-
"t3": [[], []]
19+
"t3": [[], []],
20+
"v": "text"
2021
}

0 commit comments

Comments
 (0)