diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-01-31 17:57:58 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-01-31 18:01:36 +0000 |
commit | 0da4f606b85007f6c1bdfc9255ccef8307dabb11 (patch) | |
tree | 4f774ba473b270e93614411537f7dd4e00745ebb /apps | |
parent | f4d9a124ef53eced6afc9369e14a7e419079d952 (diff) | |
download | mupdf-0da4f606b85007f6c1bdfc9255ccef8307dabb11.tar.xz |
Make pdfclean more resilient to errors while parsing.
Just add some fz_try/fz_catches.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/mupdfclean.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/apps/mupdfclean.c b/apps/mupdfclean.c index 8a163502..bd04825a 100644 --- a/apps/mupdfclean.c +++ b/apps/mupdfclean.c @@ -90,16 +90,23 @@ static void sweepref(fz_obj *obj) uselist[num] = 1; /* Bake in /Length in stream objects */ - if (pdf_is_stream(xref, num, gen)) + fz_try(ctx) { - fz_obj *len = fz_dict_gets(obj, "Length"); - if (fz_is_indirect(len)) + if (pdf_is_stream(xref, num, gen)) { - uselist[fz_to_num(len)] = 0; - len = fz_resolve_indirect(len); - fz_dict_puts(obj, "Length", len); + fz_obj *len = fz_dict_gets(obj, "Length"); + if (fz_is_indirect(len)) + { + uselist[fz_to_num(len)] = 0; + len = fz_resolve_indirect(len); + fz_dict_puts(obj, "Length", len); + } } } + fz_catch(ctx) + { + /* Leave broken */ + } sweepobj(fz_resolve_indirect(obj)); } @@ -128,8 +135,15 @@ static void removeduplicateobjs(void) * pdf_is_stream calls pdf_cache_object and ensures * that the xref table has the objects loaded. */ - if (pdf_is_stream(xref, num, 0) || pdf_is_stream(xref, other, 0)) - continue; + fz_try(ctx) + { + if (pdf_is_stream(xref, num, 0) || pdf_is_stream(xref, other, 0)) + continue; + } + fz_catch(ctx) + { + /* Assume different */ + } a = xref->table[num].obj; b = xref->table[other].obj; |