diff options
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-annot.c | 14 | ||||
-rw-r--r-- | source/pdf/pdf-xref.c | 6 |
2 files changed, 9 insertions, 11 deletions
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index b66cdba0..5e50f0a2 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -477,7 +477,7 @@ static const char *annot_type_str(fz_annot_type type) pdf_annot * pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page) { - pdf_annot *annot, *head, *tail, **itr; + pdf_annot *annot, *head, **itr; pdf_obj *obj, *ap, *as, *n, *rect; int i, len, is_dict; fz_context *ctx = doc->ctx; @@ -486,7 +486,7 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page) fz_var(itr); fz_var(head); - head = tail = NULL; + head = NULL; len = pdf_array_len(annots); /* @@ -497,6 +497,7 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page) */ fz_try(ctx) { + itr = &head; for (i = 0; i < len; i++) { obj = pdf_array_get(annots, i); @@ -505,13 +506,8 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page) annot->page = page; annot->next = NULL; - if (!head) - head = tail = annot; - else - { - tail->next = annot; - tail = annot; - } + *itr = annot; + itr = &annot->next; } } fz_catch(ctx) diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index cc4a076b..91083468 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -107,16 +107,18 @@ pdf_xref_entry *pdf_get_populating_xref_entry(pdf_document *doc, int num) } /* Ensure all xref sections map this entry */ - for (i = 0; i < doc->num_xref_sections; i++) + for (i = doc->num_xref_sections - 1; i >= 0; i--) { xref = &doc->xref_sections[i]; if (num >= xref->len) pdf_resize_xref(doc->ctx, xref, num+1); + else + break; /* Remaining sections already of sufficient size */ } /* Loop leaves xref pointing at the populating section */ - return &xref->table[num]; + return &doc->xref_sections[doc->num_xref_sections-1].table[num]; } /* Used after loading a document to access entries */ |