You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_fuzz.c 616 B

1234567891011121314151617181920212223242526
  1. #include <stdint.h>
  2. #include <json.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. int main(int argc, char *argv[]) {
  6. if (argc < 2) exit(1);
  7. FILE *f = fopen(argv[1], "r");
  8. if (!f) exit(2);
  9. fseek(f, 0, SEEK_END);
  10. unsigned long len = (unsigned long)ftell(f);
  11. fseek(f, 0, SEEK_SET);
  12. char *input = malloc(len);
  13. if (!input) exit(3);
  14. size_t r = fread(input, len, 1, f);
  15. if (r != 1) exit(4);
  16. json_global_set_string_hash(JSON_C_STR_HASH_PERLLIKE);
  17. json_tokener *tok = json_tokener_new();
  18. json_object *obj = json_tokener_parse_ex(tok, input, len);
  19. json_object_put(obj);
  20. json_tokener_free(tok);
  21. }