diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-repair.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c index 6e8405cb..b0c56be0 100644 --- a/source/pdf/pdf-repair.c +++ b/source/pdf/pdf-repair.c @@ -318,12 +318,15 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc) n = fz_read(ctx, doc->file, (unsigned char *)buf->scratch, fz_mini(buf->size, 1024)); fz_seek(ctx, doc->file, 0, 0); - for (j = 0; j < n - 4; j++) + if (n >= 4) { - if (memcmp(&buf->scratch[j], "%PDF", 4) == 0) + for (j = 0; j < n - 4; j++) { - fz_seek(ctx, doc->file, j + 8, 0); /* skip "%PDF-X.Y" */ - break; + if (memcmp(&buf->scratch[j], "%PDF", 4) == 0) + { + fz_seek(ctx, doc->file, j + 8, 0); /* skip "%PDF-X.Y" */ + break; + } } } |