/src/jsoncons/fuzzers/fuzz_cbor.cpp
Line | Count | Source |
1 | | #include <jsoncons_ext/cbor/cbor.hpp> |
2 | | #include <jsoncons_ext/cbor/cbor_reader.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 | 12.1k | { |
13 | 12.1k | std::string input(reinterpret_cast<const char*>(data), size); |
14 | 12.1k | std::istringstream is(input); |
15 | 12.1k | try { |
16 | 12.1k | json j2 = decode_cbor<json>(is); |
17 | 12.1k | } |
18 | 12.1k | catch(const jsoncons::ser_error&) {} |
19 | 12.1k | catch(jsoncons::json_runtime_error<std::runtime_error> e2) {} |
20 | | |
21 | 12.1k | return 0; |
22 | 12.1k | } |