/src/jsoncons/fuzzers/fuzz_cbor_cursor.cpp
Line | Count | Source |
1 | | #include <jsoncons_ext/cbor/cbor.hpp> |
2 | | #include <jsoncons_ext/cbor/cbor_cursor.hpp> |
3 | | |
4 | | #include <jsoncons/json.hpp> |
5 | | |
6 | | #include <sstream> |
7 | | |
8 | | using namespace jsoncons; |
9 | | using namespace jsoncons::cbor; |
10 | | |
11 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, std::size_t size) |
12 | 11.4k | { |
13 | 11.4k | std::string s(reinterpret_cast<const char*>(data), size); |
14 | 11.4k | std::istringstream is(s); |
15 | | |
16 | 11.4k | std::error_code ec; |
17 | 11.4k | cbor_stream_cursor cursor(is, ec); |
18 | 18.6k | while (!cursor.done() && !ec) |
19 | 7.23k | { |
20 | 7.23k | const auto& event = cursor.current(); |
21 | 7.23k | std::string s2 = event.get<std::string>(ec); |
22 | 7.23k | if (!ec) |
23 | 6.85k | { |
24 | 6.85k | cursor.next(ec); |
25 | 6.85k | } |
26 | 7.23k | } |
27 | | |
28 | 11.4k | return 0; |
29 | 11.4k | } |