Added a first fuzzer.

This commit is contained in:
davkor 2020-04-13 17:33:58 +01:00
parent 6c4ed0409d
commit 4faa129b8e
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#include <stdint.h>
#include <string.h>
#include <janet.h>
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){
char *new_str = (char *)malloc(size+1);
if (new_str == NULL){
return 0;
}
memcpy(new_str, data, size);
new_str[size] = '\0';
/* janet logic */
janet_init();
JanetTable *env = janet_core_env(NULL);
janet_dostring(env, new_str, "main", NULL);
janet_deinit();
free(new_str);
return 0;
}