commit 86fecbce404a9379c4e33837101ba43713fcc9bb from: pompolic date: Fri Mar 05 19:58:10 2021 UTC Merge branch 'fix-aux-xrefs-segfault' into 'master' Fix segfault when `decode_stream` fails in xrefs See merge request pesco/pdf!17 commit - 79dc4dd64dee4c459207a6f7c8c1cd18c824fda7 commit + 86fecbce404a9379c4e33837101ba43713fcc9bb blob - d4b299da2f823e3a5394cfbf9c7ae8860a9fc490 blob + fc41174066a20089dd8043518b6c4f7c3a790484 --- pdf.c +++ pdf.c @@ -2359,12 +2359,11 @@ parse_xrefs(const uint8_t *input, size_t sz, size_t *n //res = h_parse(p_xref, input + offset, sz - offset); HParser *p = h_right(h_seek(offset * 8, SEEK_SET), p_xref); // XXX res = h_parse(p, input, sz); - if (res == NULL) { + if (res == NULL || res->ast == NULL || H_INDEX_TOKEN(res->ast, 0) == NULL) { fprintf(stderr, "%s: error parsing xref section at " "position %zu (%#zx)\n", infile, offset, offset); break; } - assert(res->ast != NULL); /* save this section in xrefs */ if (n >= SIZE_MAX / sizeof(HParsedToken *))