From 0ab03af67d5e35ab305e5915e38e71e2c7f6306a Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 24 Nov 2011 16:10:40 +0000 Subject: Bug 692506: Improve repairing by accepting broken dictionaries. Adopt Zenikos patch from bug 692506; if a dict fails to parse, then create an empty one and continue. The repaired document will be incomplete, but we may well get something useful out of it. --- pdf/pdf_repair.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pdf') diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index 08adcb99..dc376dc3 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -36,7 +36,10 @@ pdf_repair_obj(fz_stream *file, char *buf, int cap, int *stmofsp, int *stmlenp, /* Send NULL xref so we don't try to resolve references */ error = pdf_parse_dict(&dict, NULL, file, buf, cap); if (error) - return fz_rethrow(error, "cannot parse object"); + { + fz_catch(error, "cannot parse object - repair will be incomplete"); + dict = fz_new_dict(2); + } obj = fz_dict_gets(dict, "Type"); if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "XRef")) -- cgit v1.2.3