summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2009-05-02 02:52:18 +0200
committerSebastian Rasmussen <sebras@hotmail.com>2009-05-02 02:52:18 +0200
commitf436165a412171736ce58abdb6c8563f09bcafd7 (patch)
tree14178e89e79d7a0b734e18e0657acf845d57d2eb
parent993daa9b143473ea628da204625d8844ba5340aa (diff)
downloadmupdf-f436165a412171736ce58abdb6c8563f09bcafd7.tar.xz
Handle missing page count in page tree by dynamically enlarging it.
-rw-r--r--mupdf/pdf_pagetree.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mupdf/pdf_pagetree.c b/mupdf/pdf_pagetree.c
index ac06a370..7a8b4556 100644
--- a/mupdf/pdf_pagetree.c
+++ b/mupdf/pdf_pagetree.c
@@ -77,6 +77,15 @@ loadpagetree(pdf_xref *xref, pdf_pagetree *pages,
if (error) return fz_rethrow(error, "cannot inherit page tree rotate");
}
+ if (pages->cursor >= pages->count)
+ {
+ fz_warn("initial page tree size too small, enlarging");
+
+ pages->count = pages->cursor + 1;
+ pages->pref = fz_realloc(pages->pref, sizeof(fz_obj*) * pages->count);
+ pages->pobj = fz_realloc(pages->pobj, sizeof(fz_obj*) * pages->count);
+ }
+
pages->pref[pages->cursor] = fz_keepobj(ref);
pages->pobj[pages->cursor] = fz_keepobj(obj);
pages->cursor ++;