diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2017-09-22 17:39:56 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-09-22 17:49:45 +0200 |
commit | 9c83cbb80b08dadb575c62790e4084f04307a2e5 (patch) | |
tree | 61f8c8ef9d54a94166fefb84ee1d4e12cbe23a4e /source/pdf/pdf-repair.c | |
parent | d2446f9005b58ebdf03b99a6d57034031269ac09 (diff) | |
download | mupdf-9c83cbb80b08dadb575c62790e4084f04307a2e5.tar.xz |
Skip to next whitespace character instead of aborting when repairing PDF.
Diffstat (limited to 'source/pdf/pdf-repair.c')
-rw-r--r-- | source/pdf/pdf-repair.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c index 4e8b4bdf..29d11e55 100644 --- a/source/pdf/pdf-repair.c +++ b/source/pdf/pdf-repair.c @@ -285,6 +285,11 @@ orphan_object(fz_context *ctx, pdf_document *doc, pdf_obj *obj) doc->orphans[doc->orphans_count++] = obj; } +static int is_white(int c) +{ + return c == '\x00' || c == '\x09' || c == '\x0a' || c == '\x0c' || c == '\x0d' || c == '\x20'; +} + void pdf_repair_xref(fz_context *ctx, pdf_document *doc) { @@ -373,14 +378,15 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot tell in file"); fz_try(ctx) - { tok = pdf_lex_no_string(ctx, doc->file, buf); - } fz_catch(ctx) { fz_rethrow_if(ctx, FZ_ERROR_TRYLATER); - fz_warn(ctx, "ignoring the rest of the file"); - break; + fz_warn(ctx, "skipping ahead to next token"); + do + c = fz_read_byte(ctx, doc->file); + while (c != EOF && !is_white(c)); + continue; } /* If we have the next token already, then we'll jump |