Coverage Report

Created: 2025-08-28 06:40

/src/jq/tests/jq_fuzz_compile.c
Line
Count
Source
1
#include <stdint.h>
2
#include <stdlib.h>
3
#include <string.h>
4
5
#include "jq.h"
6
7
1.24k
int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
8
  // Creat null-terminated string
9
1.24k
  char *null_terminated = (char *)malloc(size + 1);
10
1.24k
  memcpy(null_terminated, (char *)data, size);
11
1.24k
  null_terminated[size] = '\0';
12
13
  // Fuzzer entrypoint
14
1.24k
  jq_state *jq = NULL;
15
1.24k
  jq = jq_init();
16
1.24k
  if (jq != NULL) {
17
1.24k
    if (jq_compile(jq, null_terminated)) {
18
317
      jq_dump_disassembly(jq, 2);
19
317
    }
20
1.24k
  }
21
1.24k
  jq_teardown(&jq);
22
23
  // Free the null-terminated string
24
1.24k
  free(null_terminated);
25
26
1.24k
  return 0;
27
1.24k
}