From 5b8ce880027d37aa57ad387134303d160b19ee81 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 13 Feb 2018 15:59:54 +0100 Subject: Avoid revisiting the same page tree node repeatedly. Only attempt to progress to new page tree nodes if a new node to process has actually been found. Previously if e.g. doc.findPage(1) was called in murun for a single page document the error message was "cycle in page tree" because the single page tree node was visited twice. Now the error message is "cannot find page 1 in page tree", which is more accurate. --- source/pdf/pdf-page.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/pdf') diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 9d8a27ec..f5ab501b 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -174,7 +174,13 @@ pdf_lookup_page_loc_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int * } } } - while (hit == NULL); + /* If i < len && hit != NULL the desired page was found in the + Kids array, done. If i < len && hit == NULL the found page tree + node contains a Kids array that contains the desired page, loop + back to top to extract it. When i == len the Kids array has been + exhausted without finding the desired page, give up. + */ + while (hit == NULL && i < len); } fz_always(ctx) { -- cgit v1.2.3