From 8279276d5b817a051c0cd9333f0c385ab7acd944 Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Thu, 28 Jul 2022 11:51:55 +0100 Subject: [PATCH] Add fuzzer Signed-off-by: AdamKorcz --- test/fuzzer.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/fuzzer.c diff --git a/test/fuzzer.c b/test/fuzzer.c new file mode 100644 index 00000000..b0e616f1 --- /dev/null +++ b/test/fuzzer.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include "../jsmn.h" + +extern "C" +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){ + char *js = (char *)malloc(size+1); + if (js == NULL){ + return 0; + } + memcpy(js, data, size); + js[size] = '\0'; + + int r; + jsmn_parser p; + jsmntok_t tokens[128]; + jsmn_init(&p); + r = jsmn_parse(&p, js, strlen(js), tokens, 128); + + + free(js); + return 0; +}