summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz/stream.h
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-01-09 13:52:41 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-01-10 16:06:17 +0100
commitb70eb93f6936c03d8af52040bbca4d4a7db39079 (patch)
tree338ab1f1e7c75c6c02619b212863d33dea5ec602 /include/mupdf/fitz/stream.h
parent0d7359fbcd331ec0a22ec163dacff953f9817814 (diff)
downloadmupdf-b70eb93f6936c03d8af52040bbca4d4a7db39079.tar.xz
Don't allow reading from a 'dead' fz_stream.
Once a stream has thrown an exception or reached EOF, don't allow further reading. The EOF flag is reset when fz_seek is invoked.
Diffstat (limited to 'include/mupdf/fitz/stream.h')
-rw-r--r--include/mupdf/fitz/stream.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/mupdf/fitz/stream.h b/include/mupdf/fitz/stream.h
index cd26be90..790a0a83 100644
--- a/include/mupdf/fitz/stream.h
+++ b/include/mupdf/fitz/stream.h
@@ -335,10 +335,11 @@ static inline size_t fz_available(fz_context *ctx, fz_stream *stm, size_t max)
if (len)
return len;
+ if (stm->eof)
+ return 0;
+
fz_try(ctx)
- {
c = stm->next(ctx, stm, max);
- }
fz_catch(ctx)
{
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
@@ -369,10 +370,10 @@ static inline int fz_read_byte(fz_context *ctx, fz_stream *stm)
if (stm->rp != stm->wp)
return *stm->rp++;
+ if (stm->eof)
+ return EOF;
fz_try(ctx)
- {
c = stm->next(ctx, stm, 1);
- }
fz_catch(ctx)
{
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
@@ -398,6 +399,8 @@ static inline int fz_peek_byte(fz_context *ctx, fz_stream *stm)
if (stm->rp != stm->wp)
return *stm->rp;
+ if (stm->eof)
+ return EOF;
fz_try(ctx)
{