1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-20 15:44:49 +00:00

Merge pull request #344 from DavidKorczynski/master

Added a fuzzer and integration with OSS-Fuzz.
This commit is contained in:
Calvin Rose 2020-04-16 18:50:07 -05:00 committed by GitHub
commit 557988e530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}