Skip to content
Myr

jq_fuzz_parse_stream.c

This file

Path

tests/jq_fuzz_parse_stream.c

33 lines · 937 bytes · C

Last changed by

fix jq_fuzz_parse_stream: use iterative parser API for streaming mode (#3499)Ze Shengbefore adoptionb6a9e26

History of this file

Take it

The walk stopped after 200 commits: lines older than fa6a2ff point at it.

website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff

lines 1–7why, one step back
1#include <stdint.h>
2#include <stdlib.h>3#include <string.h>45#include "jv.h"67int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {

fix jq_fuzz_parse_stream: use iterative parser API for streaming mode (#3499)Ze Shengbefore adoptionb6a9e26

line 8why, one step back
8 // Create null-terminated string

website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff

lines 9–12why, one step back
9 char *null_terminated = (char *)malloc(size + 1);
10 memcpy(null_terminated, (char *)data, size);11 null_terminated[size] = '\0';12

fix jq_fuzz_parse_stream: use iterative parser API for streaming mode (#3499)Ze Shengbefore adoptionb6a9e26

lines 13–28why, one step back
13 // Use the iterative jv_parser API for streaming mode.
14 // The single-shot jv_parse_custom_flags() returns "Unexpected extra JSON15 // values" for any compound JSON in streaming mode, because the streaming16 // parser produces multiple tokens but the single-shot API expects exactly17 // one value.18 jv_parser *parser = jv_parser_new(JV_PARSE_STREAMING);19 jv_parser_set_buf(parser, null_terminated, (int)size, 0);2021 jv value;22 while (jv_is_valid(value = jv_parser_next(parser))) {23 jv_free(value);24 }25 jv_free(value);2627 jv_parser_free(parser);28

website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff

lines 29–33why, one step back
29 // Free the null-terminated string
30 free(null_terminated);3132 return 0;33}