3 /* Fuzz XML parsing and writing. */
4 int LLVMFuzzerTestOneInput(const uint8_t *in, size_t insize)
11 if (!setup_fault_nth(&in, &insize, &fault_nth))
14 in_str = malloc(insize + 1);
15 memcpy(in_str, in, insize);
16 in_str[insize] = '\0';
17 ret = wimlib_parse_and_write_xml_doc(in_str, &out_str);
19 char *out2_str = NULL;
22 * If the first parse+write succeeded, we now should be able to
23 * parse+write the result without changing it further.
25 ret = wimlib_parse_and_write_xml_doc(out_str, &out2_str);
27 assert(ret == WIMLIB_ERR_NOMEM && fault_nth);
29 assert(strcmp(out_str, out2_str) == 0);
32 assert(ret == WIMLIB_ERR_XML ||
33 (fault_nth && ret == WIMLIB_ERR_NOMEM));