1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00
stedolan-jq/tests/jq_fuzz_compile.c
David Korczynski cf3c11bde8 Add compile fuzzer for OSS-Fuzz
Signed-off-by: David Korczynski <david@adalogics.com>
2023-07-24 13:44:27 +02:00

26 lines
524 B
C

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "jq.h"
int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
// Creat null-terminated string
char *null_terminated = (char *)malloc(size + 1);
memcpy(null_terminated, (char *)data, size);
null_terminated[size] = '\0';
// Fuzzer entrypoint
jq_state *jq = NULL;
jq = jq_init();
if (jq != NULL) {
jq_compile(jq, null_terminated);
}
jq_teardown(&jq);
// Free the null-terminated string
free(null_terminated);
return 0;
}