summaryrefslogtreecommitdiff
path: root/pdf/pdf_repair.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-06-22 13:26:35 +0100
committerRobin Watts <robin.watts@artifex.com>2012-06-22 16:42:09 +0100
commitb4157f3585c0f7a07305ac324e7ab9d47e7d04ae (patch)
treed993f31a9fb04e9b833ca042e2aa8088e393999c /pdf/pdf_repair.c
parent34fc2fb23d9f0a9b2a68896e608ea149d8bc38e2 (diff)
downloadmupdf-b4157f3585c0f7a07305ac324e7ab9d47e7d04ae.tar.xz
Rework pdf_lexbuf to allow for dynamic parsing buffers.
Currently pdf_lexbufs use a static scratch buffer for parsing. In the main case this is 64K in size, but in other cases it can be just 256 bytes; this causes problems when parsing long strings. Even the 64K limit is an implementation limit of Acrobat, not an architectural limit of PDF. Change here to allow dynamic buffers. This means a slightly more complex setup and destruction for each buffer, but more importantly requires correct cleanup on errors. To avoid having to insert lots more try/catch clauses this commit includes various changes to the code so we reuse pdf_lexbufs where possible. This keeps the speed up.
Diffstat (limited to 'pdf/pdf_repair.c')
-rw-r--r--pdf/pdf_repair.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c
index 27846855..85709219 100644
--- a/pdf/pdf_repair.c
+++ b/pdf/pdf_repair.c
@@ -151,7 +151,7 @@ pdf_repair_obj_stm(pdf_document *xref, int num, int gen)
fz_var(stm);
- buf.size = PDF_LEXBUF_SMALL;
+ pdf_lexbuf_init(ctx, &buf, PDF_LEXBUF_SMALL);
fz_try(ctx)
{
@@ -188,6 +188,7 @@ pdf_repair_obj_stm(pdf_document *xref, int num, int gen)
fz_always(ctx)
{
fz_close(stm);
+ pdf_lexbuf_fin(&buf);
}
fz_catch(ctx)
{