diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-02-15 15:52:07 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-02-15 15:54:08 +0000 |
commit | 1a7a480ccd18ff6354de528b6c1cf3d486cf5753 (patch) | |
tree | 941476e8b7ce3f7e7b74fbcde0851fad6b461cfe | |
parent | 9dff76970f81c44d8f07f5d585bbeb96fdb56c76 (diff) | |
download | mupdf-1a7a480ccd18ff6354de528b6c1cf3d486cf5753.tar.xz |
Treat 0000000000 * n xref entries as free ones.
Quartz generated PDFs (and maybe others too) seem to use
000000000 65536 n to mean "free object" in defiance of the
spec. Add special case code to mupdf to handle this.
-rw-r--r-- | pdf/pdf_xref.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c index 41a7ba3a..102037f6 100644 --- a/pdf/pdf_xref.c +++ b/pdf/pdf_xref.c @@ -469,7 +469,11 @@ pdf_load_xref(pdf_document *xref, char *buf, int bufsize) for (i = 0; i < xref->len; i++) { if (xref->table[i].type == 'n') - if (xref->table[i].ofs <= 0 || xref->table[i].ofs >= xref->file_size) + /* Special case code: "0000000000 * f" means free, + * according to some producers (inc Quartz) */ + if (xref->table[i].ofs == 0) + xref->table[i].type = 'f'; + else if (xref->table[i].ofs <= 0 || xref->table[i].ofs >= xref->file_size) fz_throw(ctx, "object offset out of range: %d (%d 0 R)", xref->table[i].ofs, i); if (xref->table[i].type == 'o') if (xref->table[i].ofs <= 0 || xref->table[i].ofs >= xref->len || xref->table[xref->table[i].ofs].type != 'n') |