From 557ebf4323249dc80c711b286d189be39f765b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCnzli?= Date: Mon, 10 Feb 2014 21:41:26 +0100 Subject: 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. --- source/pdf/pdf-xref.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/pdf/pdf-xref.c') 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 */ -- cgit v1.2.3