summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2010-12-30 01:13:58 +0000
committerSebastian Rasmussen <sebras@hotmail.com>2010-12-30 01:13:58 +0000
commit9ef942a0713f837c872a8ab28275bba1000792d3 (patch)
tree591aaa147dd5a1d15d7b082d42b641c1d4b095bb
parentcc713fcab272fa9a626bb62d5a2a006c3ac58b68 (diff)
downloadmupdf-9ef942a0713f837c872a8ab28275bba1000792d3.tar.xz
Repair xref before repairing the trailer.
-rw-r--r--mupdf/pdf_repair.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/mupdf/pdf_repair.c b/mupdf/pdf_repair.c
index a3f2653c..48472314 100644
--- a/mupdf/pdf_repair.c
+++ b/mupdf/pdf_repair.c
@@ -281,34 +281,10 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
break;
}
- /* create a repaired trailer, Root will be added later */
-
- xref->trailer = fz_newdict(4);
-
- obj = fz_newint(maxnum + 1);
- fz_dictputs(xref->trailer, "Size", obj);
- fz_dropobj(obj);
-
- if (encrypt)
- {
- fz_dictputs(xref->trailer, "Encrypt", encrypt);
- fz_dropobj(encrypt);
- }
-
- if (id)
- {
- fz_dictputs(xref->trailer, "ID", id);
- fz_dropobj(id);
- }
+ /* make xref reasonable */
pdf_resizexref(xref, maxnum + 1);
- xref->table[0].type = 'f';
- xref->table[0].ofs = 0;
- xref->table[0].gen = 65535;
- xref->table[0].stmofs = 0;
- xref->table[0].obj = nil;
-
for (i = 0; i < listlen; i++)
{
xref->table[list[i].num].type = 'n';
@@ -339,6 +315,12 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
}
+ xref->table[0].type = 'f';
+ xref->table[0].ofs = 0;
+ xref->table[0].gen = 65535;
+ xref->table[0].stmofs = 0;
+ xref->table[0].obj = nil;
+
next = 0;
for (i = xref->len - 1; i >= 0; i--)
{
@@ -351,6 +333,27 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize)
}
}
+ /* create a repaired trailer, Root will be added later */
+
+ xref->trailer = fz_newdict(4);
+
+ obj = fz_newint(maxnum + 1);
+ fz_dictputs(xref->trailer, "Size", obj);
+ fz_dropobj(obj);
+
+ if (encrypt)
+ {
+ fz_dictputs(xref->trailer, "Encrypt", encrypt);
+ fz_dropobj(encrypt);
+ }
+
+ if (id)
+ {
+ fz_dictputs(xref->trailer, "ID", id);
+ fz_dropobj(id);
+ }
+
+
fz_free(list);
return fz_okay;