summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2013-09-13 20:52:15 +0200
committerSimon Bünzli <zeniko@gmail.com>2013-09-27 16:24:26 +0200
commite6ad4dbd07ecffdb764a58977a013c862263355b (patch)
tree9e9a5489a9166995e0f988897c4034d953ae6058 /source/pdf
parent2c615e5aa18c7a34118605774de70b6b65f04b19 (diff)
downloadmupdf-e6ad4dbd07ecffdb764a58977a013c862263355b.tar.xz
stop checking if the result of fz_read is negative
fz_read used to return a negative value on errors. With the introduction of fz_try/fz_catch, it throws an error instead and always returns non-negative values. This removes the pointless checks.
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-repair.c7
-rw-r--r--source/pdf/pdf-xref.c6
2 files changed, 3 insertions, 10 deletions
diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c
index 8fedbeff..c742714d 100644
--- a/source/pdf/pdf-repair.c
+++ b/source/pdf/pdf-repair.c
@@ -19,7 +19,6 @@ pdf_repair_obj(pdf_document *doc, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, p
{
pdf_token tok;
int stm_len;
- int n;
fz_stream *file = doc->file;
fz_context *ctx = file->ctx;
@@ -134,9 +133,7 @@ pdf_repair_obj(pdf_document *doc, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, p
fz_seek(file, *stmofsp, 0);
}
- n = fz_read(file, (unsigned char *) buf->scratch, 9);
- if (n < 0)
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot read from file");
+ (void)fz_read(file, (unsigned char *) buf->scratch, 9);
while (memcmp(buf->scratch, "endstream", 9) != 0)
{
@@ -285,8 +282,6 @@ pdf_repair_xref(pdf_document *doc, pdf_lexbuf *buf)
/* look for '%PDF' version marker within first kilobyte of file */
n = fz_read(doc->file, (unsigned char *)buf->scratch, fz_mini(buf->size, 1024));
- if (n < 0)
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot read from file");
fz_seek(doc->file, 0, 0);
for (i = 0; i < n - 4; i++)
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 6d440418..fbadd0a4 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -309,8 +309,6 @@ pdf_read_start_xref(pdf_document *doc)
fz_seek(doc->file, t, SEEK_SET);
n = fz_read(doc->file, buf, sizeof buf);
- if (n < 0)
- fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot read from file");
for (i = n - 9; i >= 0; i--)
{
@@ -467,8 +465,8 @@ pdf_read_old_xref(pdf_document *doc, pdf_lexbuf *buf)
{
pdf_xref_entry *entry = pdf_get_populating_xref_entry(doc, i);
n = fz_read(doc->file, (unsigned char *) buf->scratch, 20);
- if (n < 0)
- fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot read xref table");
+ if (n != 20)
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "unexpected EOF in xref table");
if (!entry->type)
{
s = buf->scratch;