From bff572a7365209f36a16951296384974c80ad3d5 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 18 Nov 2016 13:02:01 +0100 Subject: Harden viewers against failures when loading outlines. Ignore invalid page references in outlines. This was shown by a file that had [null 0 0 1] as a link dest. Attempting to parse that threw an error, which caused the whole outline load to fail. --- source/pdf/pdf-annot.c | 7 ++++++- source/pdf/pdf-outline.c | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index 2d6aab16..6f622da4 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -67,7 +67,12 @@ pdf_parse_link_dest(fz_context *ctx, pdf_document *doc, pdf_obj *dest) if (pdf_is_int(ctx, obj)) page = pdf_to_int(ctx, obj); else - page = pdf_lookup_page_number(ctx, doc, obj); + { + fz_try(ctx) + page = pdf_lookup_page_number(ctx, doc, obj); + fz_catch(ctx) + page = -1; + } x = y = 0; obj = pdf_array_get(ctx, dest, 1); diff --git a/source/pdf/pdf-outline.c b/source/pdf/pdf-outline.c index 7db65153..c31a1954 100644 --- a/source/pdf/pdf-outline.c +++ b/source/pdf/pdf-outline.c @@ -33,7 +33,10 @@ pdf_load_outline_imp(fz_context *ctx, pdf_document *doc, pdf_obj *dict) else node->uri = NULL; - node->page = pdf_resolve_link(ctx, doc, node->uri, NULL, NULL); + if (node->uri) + node->page = pdf_resolve_link(ctx, doc, node->uri, NULL, NULL); + else + node->page = -1; obj = pdf_dict_get(ctx, dict, PDF_NAME_First); if (obj) -- cgit v1.2.3