summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-01-09 14:20:01 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-01-10 16:06:13 +0100
commit0d7359fbcd331ec0a22ec163dacff953f9817814 (patch)
tree04e27771c64fe9cb7df16e5feb4cbd67a91c419e /include
parentb840e169b486850867f71faf0cdd30e329170f30 (diff)
downloadmupdf-0d7359fbcd331ec0a22ec163dacff953f9817814.tar.xz
Handle exceptions in fz_peek_byte the same way as in fz_read_byte.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/stream.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/include/mupdf/fitz/stream.h b/include/mupdf/fitz/stream.h
index e336fd5d..cd26be90 100644
--- a/include/mupdf/fitz/stream.h
+++ b/include/mupdf/fitz/stream.h
@@ -399,9 +399,21 @@ static inline int fz_peek_byte(fz_context *ctx, fz_stream *stm)
if (stm->rp != stm->wp)
return *stm->rp;
- c = stm->next(ctx, stm, 1);
- if (c != EOF)
- stm->rp--;
+ fz_try(ctx)
+ {
+ c = stm->next(ctx, stm, 1);
+ if (c != EOF)
+ stm->rp--;
+ }
+ fz_catch(ctx)
+ {
+ fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
+ fz_warn(ctx, "read error; treating as end of file");
+ stm->error = 1;
+ c = EOF;
+ }
+ if (c == EOF)
+ stm->eof = 1;
return c;
}