From 0d7359fbcd331ec0a22ec163dacff953f9817814 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 9 Jan 2018 14:20:01 +0100 Subject: Handle exceptions in fz_peek_byte the same way as in fz_read_byte. --- include/mupdf/fitz/stream.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'include') 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; } -- cgit v1.2.3