summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-06-25 15:32:02 +0100
committerRobin Watts <robin.watts@artifex.com>2013-06-25 15:37:25 +0100
commit148e6b9dae3900f1acd053df10bc41f06be5c507 (patch)
treed1e5e7652920ed262f8fb5b069c052cf8f2ff094 /source/pdf
parent64140fa7f404f7499a72a255118c7243363b93dd (diff)
downloadmupdf-148e6b9dae3900f1acd053df10bc41f06be5c507.tar.xz
Ensure that xref_sections always grow over time.
Never allow a new xref_section to be smaller than a previous one, as this makes pdf_xref_len(xref) get unexpectedly smaller.
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-xref.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 9aa1eab6..001fa62d 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -67,6 +67,11 @@ static void pdf_populate_next_xref_level(pdf_document *doc)
xref->len = 0;
xref->table = NULL;
xref->trailer = NULL;
+ /* All new levels must be at least as big as the level before */
+ if (doc->num_xref_sections > 1)
+ {
+ pdf_resize_xref(doc->ctx, xref, doc->xref_sections[doc->num_xref_sections - 2].len);
+ }
}
pdf_obj *pdf_trailer(pdf_document *doc)
@@ -159,6 +164,9 @@ static pdf_xref_entry *pdf_get_new_xref_entry(pdf_document *doc, int i)
}
xref = &doc->xref_sections[0];
+ /* All new levels must be at least as big as the level before */
+ if (doc->xref_sections[1].len > i)
+ i = doc->xref_sections[1].len-1;
if (i >= xref->len)
pdf_resize_xref(ctx, xref, i + 1);