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 fileTake 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 back1#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 back8 // Create null-terminated stringwebsite: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 9–12why, one step back9 char *null_terminated = (char *)malloc(size + 1);10 memcpy(null_terminated, (char *)data, size);11 null_terminated[size] = '\0';12fix jq_fuzz_parse_stream: use iterative parser API for streaming mode (#3499)Ze Shengbefore adoptionb6a9e26
lines 13–28why, one step back13 // 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);28website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 29–33why, one step back29 // Free the null-terminated string30 free(null_terminated);3132 return 0;33}