diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-06-28 17:31:14 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-07-11 10:46:42 +0100 |
commit | d96c171dc9675edb1d1b08ed2291b76b291b03ac (patch) | |
tree | 1c6ed203e432cd92b9d4d07688e563dea224b289 /source | |
parent | 67699ce1711721677f60afd191611c39d92c66fb (diff) | |
download | mupdf-d96c171dc9675edb1d1b08ed2291b76b291b03ac.tar.xz |
Fix pdf_count_pages_before_kid to cope with /Page with /Count in.
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-page.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 73e1a9b7..9f802927 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -100,16 +100,21 @@ pdf_lookup_page_obj(pdf_document *doc, int needle) static int pdf_count_pages_before_kid(pdf_document *doc, pdf_obj *parent, int kid_num) { - pdf_obj *count, *kid, *kids = pdf_dict_gets(parent, "Kids"); + pdf_obj *kids = pdf_dict_gets(parent, "Kids"); int i, total = 0, len = pdf_array_len(kids); for (i = 0; i < len; i++) { - kid = pdf_array_get(kids, i); + pdf_obj *kid = pdf_array_get(kids, i); if (pdf_to_num(kid) == kid_num) return total; - count = pdf_dict_gets(kid, "Count"); - if (count) - total += pdf_to_int(count); + if (!strcmp(pdf_to_name(pdf_dict_gets(kid, "Type")), "Pages")) + { + pdf_obj *count = pdf_dict_gets(kid, "Count"); + int n = pdf_to_int(count); + if (count == NULL || n <= 0) + fz_throw(doc->ctx, FZ_ERROR_GENERIC, "illegal or missing count in pages tree"); + total += n; + } else total++; } |