Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
punchfox authored Mar 11, 2021
2 parents 4619180 + 3a599d8 commit 0a0c782
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions fuzzers/fuzz_decode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <string>
#include <stdint.h>
#include <spotify/json/codec/number.hpp>
#include <spotify/json/codec/object.hpp>
#include <spotify/json/decode.hpp>
#include <spotify/json/encoded_value.hpp>

namespace {
struct custom_obj {
std::string val;
};
}

template <>
struct spotify::json::default_codec_t<custom_obj> {
static codec::object_t<custom_obj> codec() {
auto codec = codec::object<custom_obj>();
codec.required("x", &custom_obj::val);
return codec;
}
};

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
custom_obj obj;
std::string input(reinterpret_cast<const char*>(data), size);
spotify::json::try_decode(obj, input);
return 0;
}

0 comments on commit 0a0c782

Please sign in to comment.