Skip to content
Snippets Groups Projects
Commit a0874f26 authored by Sven M. Hallberg's avatar Sven M. Hallberg
Browse files

handle linearized PDFs with updates

parent 8b2bafbf
No related branches found
No related tags found
No related merge requests found
...@@ -1247,7 +1247,7 @@ parse_xrefs(const char *input, size_t sz, size_t *nxrefs) ...@@ -1247,7 +1247,7 @@ parse_xrefs(const char *input, size_t sz, size_t *nxrefs)
HParseResult *res = NULL; HParseResult *res = NULL;
const HParsedToken **xrefs = NULL; /* empty result */ const HParsedToken **xrefs = NULL; /* empty result */
const HParsedToken *tok = NULL; const HParsedToken *tok = NULL;
size_t n = 0; size_t n = 0, nfwd = 0;
size_t offset = 0; size_t offset = 0;
// XXX try formulating this as a parser using h_seek() // XXX try formulating this as a parser using h_seek()
...@@ -1296,10 +1296,12 @@ parse_xrefs(const char *input, size_t sz, size_t *nxrefs) ...@@ -1296,10 +1296,12 @@ parse_xrefs(const char *input, size_t sz, size_t *nxrefs)
* validate the new offset. we don't want to get caught in a * validate the new offset. we don't want to get caught in a
* loop. the offsets should strictly decrease, unless the file * loop. the offsets should strictly decrease, unless the file
* is a "linearized" PDF. in that case there should be exactly * is a "linearized" PDF. in that case there should be exactly
* two xref sections in the reverse order, so we allow the * one xref section at the beginning of the file that is
* first section to point forward. * allowed to point forward.
*/ */
if (n > 1 && tok->sint >= offset) { if (tok->sint >= offset)
nfwd++;
if (nfwd > 1) {
fprintf(stderr, "%s: /Prev pointer of xref section at " fprintf(stderr, "%s: /Prev pointer of xref section at "
"%zu (%#zx) points forward\n", infile, offset, "%zu (%#zx) points forward\n", infile, offset,
offset); offset);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment