/src/jq/tests/jq_fuzz_parse.c
Line | Count | Source |
1 | | #include <stdint.h> |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | |
5 | | #include "jv.h" |
6 | | |
7 | 5.14k | int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { |
8 | | // Creat null-terminated string |
9 | 5.14k | char *null_terminated = (char *)malloc(size + 1); |
10 | 5.14k | memcpy(null_terminated, (char *)data, size); |
11 | 5.14k | null_terminated[size] = '\0'; |
12 | | |
13 | | // Fuzzer entrypoint |
14 | 5.14k | jv res = jv_parse(null_terminated); |
15 | 5.14k | jv_free(res); |
16 | | |
17 | | // Free the null-terminated string |
18 | 5.14k | free(null_terminated); |
19 | | |
20 | 5.14k | return 0; |
21 | 5.14k | } |