summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-xref.c
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2014-02-10 21:41:26 +0100
committerRobin Watts <robin.watts@artifex.com>2014-02-11 14:29:43 +0000
commit557ebf4323249dc80c711b286d189be39f765b39 (patch)
treefb4f0bdf887b0fa043bd30a4b2c056f7606d151b /source/pdf/pdf-xref.c
parent017a901280f5471ae06667f26d4302bbf8bc5bf5 (diff)
downloadmupdf-557ebf4323249dc80c711b286d189be39f765b39.tar.xz
tolerate streamed xrefs where object 0 is missing
see https://code.google.com/p/sumatrapdf/issues/detail?id=2517 for a document which is broken to the point where it fails to load using reparation but loads successfully if object 0 is implicitly defined.
Diffstat (limited to 'source/pdf/pdf-xref.c')
-rw-r--r--source/pdf/pdf-xref.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 881826b9..9a3cfd37 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -795,6 +795,7 @@ pdf_load_xref(pdf_document *doc, pdf_lexbuf *buf)
{
int i;
int xref_len;
+ pdf_xref_entry *entry;
fz_context *ctx = doc->ctx;
pdf_read_start_xref(doc);
@@ -804,8 +805,15 @@ pdf_load_xref(pdf_document *doc, pdf_lexbuf *buf)
if (pdf_xref_len(doc) == 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "found xref was empty");
+ entry = pdf_get_xref_entry(doc, 0);
+ /* broken pdfs where first object is missing */
+ if (!entry->type)
+ {
+ entry->type = 'f';
+ entry->gen = 65535;
+ }
/* broken pdfs where first object is not free */
- if (pdf_get_xref_entry(doc, 0)->type != 'f')
+ else if (entry->type != 'f')
fz_throw(ctx, FZ_ERROR_GENERIC, "first object in xref is not free");
/* broken pdfs where object offsets are out of range */