From 1a7a480ccd18ff6354de528b6c1cf3d486cf5753 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 15 Feb 2012 15:52:07 +0000 Subject: 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. --- pdf/pdf_xref.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pdf') 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') -- cgit v1.2.3