1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-28 01:10:26 +00:00
janet/test/fuzzers/fuzz_dostring.c
2020-04-17 13:39:23 -05:00

23 lines
469 B
C

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