diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-02-13 15:59:54 +0100 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-02-13 18:22:16 +0100 |
commit | 5b8ce880027d37aa57ad387134303d160b19ee81 (patch) | |
tree | ebe4b41b13299b26ba6bebcbeb25b83f6e6616dd | |
parent | 36cfeaf99bbf6f9431cb55ab9f04a67a491299c1 (diff) | |
download | mupdf-5b8ce880027d37aa57ad387134303d160b19ee81.tar.xz |
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.
-rw-r--r-- | source/pdf/pdf-page.c | 8 |
1 files changed, 7 insertions, 1 deletions
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) { |