summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/pdf/pdf-xref.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 735f2e2e..881826b9 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -41,6 +41,7 @@ static void pdf_free_xref_sections(pdf_document *doc)
}
fz_free(ctx, xref->table);
+ pdf_drop_obj(xref->pre_repair_trailer);
pdf_drop_obj(xref->trailer);
}
@@ -76,6 +77,7 @@ static void pdf_populate_next_xref_level(pdf_document *doc)
xref->len = 0;
xref->table = NULL;
xref->trailer = NULL;
+ xref->pre_repair_trailer = NULL;
}
pdf_obj *pdf_trailer(pdf_document *doc)
@@ -90,7 +92,11 @@ void pdf_set_populating_xref_trailer(pdf_document *doc, pdf_obj *trailer)
{
/* Update the trailer of the xref section being populated */
pdf_xref *xref = &doc->xref_sections[doc->num_xref_sections - 1];
- pdf_drop_obj(xref->trailer);
+ if (xref->trailer)
+ {
+ pdf_drop_obj(xref->pre_repair_trailer);
+ xref->pre_repair_trailer = xref->trailer;
+ }
xref->trailer = pdf_keep_obj(trailer);
}
@@ -186,6 +192,7 @@ static void ensure_incremental_xref(pdf_document *doc)
/* xref->len is already correct */
xref->table = new_table;
xref->trailer = trailer;
+ xref->pre_repair_trailer = NULL;
doc->num_xref_sections++;
doc->xref_altered = 1;
}