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. --- platform/ios/Classes/MuDocumentController.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'platform/ios/Classes') diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index 532ee411..ba18dee2 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -272,7 +272,11 @@ static void saveDoc(const char *current_path, fz_document *doc) // Set up the buttons on the navigation and search bar - fz_outline *outlineRoot = fz_load_outline(ctx, doc); + fz_outline *outlineRoot; + fz_try(ctx) + outlineRoot = fz_load_outline(ctx, doc); + fz_catch(ctx) + outlineRoot = NULL; if (outlineRoot) { // only show the outline button if there is an outline @@ -471,7 +475,11 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) onShowOutline: (id)sender { // rebuild the outline in case the layout has changed - fz_outline *root = fz_load_outline(ctx, doc); + fz_outline *root; + fz_try(ctx) + root = fz_load_outline(ctx, doc); + fz_catch(ctx) + root = NULL; if (root) { NSMutableArray *titles = [[NSMutableArray alloc] init]; -- cgit v1.2.3