summaryrefslogtreecommitdiff
path: root/pdf/pdf_repair.c
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2013-06-05 15:26:26 +0100
committerPaul Gardiner <paulg.artifex@glidos.net>2013-06-05 15:32:17 +0100
commite92dd2a341223487e87a9088164725f0a40ad27c (patch)
tree1e2d844b2183f705ff0a9f539076e4d92a87d578 /pdf/pdf_repair.c
parent87ee1ceac0485a8adee93435fc6f1e5aeed6a65d (diff)
downloadmupdf-e92dd2a341223487e87a9088164725f0a40ad27c.tar.xz
Maintain the separation of xref sections when loading a document
Also on first alteration create a further section to hold the updates. This is in preparation for supporting incemental update.
Diffstat (limited to 'pdf/pdf_repair.c')
-rw-r--r--pdf/pdf_repair.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c
index 1127fe1f..e5a1a8a9 100644
--- a/pdf/pdf_repair.c
+++ b/pdf/pdf_repair.c
@@ -182,7 +182,7 @@ pdf_repair_obj_stm(pdf_document *xref, int num, int gen)
continue;
}
- entry = pdf_get_xref_entry(xref, n);
+ entry = pdf_get_populating_xref_entry(xref, n);
entry->ofs = num;
entry->gen = i;
entry->stm_ofs = 0;
@@ -405,11 +405,11 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
Dummy access to entry to assure sufficient space in the xref table
and avoid repeated reallocs in the loop
*/
- (void)pdf_get_xref_entry(xref, maxnum);
+ (void)pdf_get_populating_xref_entry(xref, maxnum);
for (i = 0; i < listlen; i++)
{
- entry = pdf_get_xref_entry(xref, list[i].num);
+ entry = pdf_get_populating_xref_entry(xref, list[i].num);
entry->type = 'n';
entry->ofs = list[i].ofs;
entry->gen = list[i].gen;
@@ -429,7 +429,7 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
}
}
- entry = pdf_get_xref_entry(xref, 0);
+ entry = pdf_get_populating_xref_entry(xref, 0);
entry->type = 'f';
entry->ofs = 0;
entry->gen = 65535;
@@ -439,7 +439,7 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
next = 0;
for (i = pdf_xref_len(xref) - 1; i >= 0; i--)
{
- entry = pdf_get_xref_entry(xref, i);
+ entry = pdf_get_populating_xref_entry(xref, i);
if (entry->type == 'f')
{
entry->ofs = next;
@@ -452,7 +452,8 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
/* create a repaired trailer, Root will be added later */
obj = pdf_new_dict(ctx, 5);
- pdf_set_xref_trailer(xref, obj);
+ /* During repair there is only a single xref section */
+ pdf_set_populating_xref_trailer(xref, obj);
pdf_drop_obj(obj);
obj = NULL;
@@ -526,7 +527,7 @@ pdf_repair_obj_stms(pdf_document *xref)
for (i = 0; i < xref_len; i++)
{
- pdf_xref_entry *entry = pdf_get_xref_entry(xref, i);
+ pdf_xref_entry *entry = pdf_get_populating_xref_entry(xref, i);
if (entry->stm_ofs)
{
@@ -550,9 +551,9 @@ pdf_repair_obj_stms(pdf_document *xref)
/* Ensure that streamed objects reside inside a known non-streamed object */
for (i = 0; i < xref_len; i++)
{
- pdf_xref_entry *entry = pdf_get_xref_entry(xref, i);
+ pdf_xref_entry *entry = pdf_get_populating_xref_entry(xref, i);
- if (entry->type == 'o' && pdf_get_xref_entry(xref, entry->ofs)->type != 'n')
+ if (entry->type == 'o' && pdf_get_populating_xref_entry(xref, entry->ofs)->type != 'n')
fz_throw(xref->ctx, "invalid reference to non-object-stream: %d (%d 0 R)", entry->ofs, i);
}
}