summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2009-08-23 16:17:58 +0200
committerSebastian Rasmussen <sebras@hotmail.com>2009-08-23 16:17:58 +0200
commit3d4ab58c8b8812be0304301df7c53020d20b8fa7 (patch)
tree93ee2f8c57f495a4db67a4ca05fa98c18e31ef8e /fitz
parentda98a190ab57f00268e3ebd11df20aa68bad2dd4 (diff)
downloadmupdf-3d4ab58c8b8812be0304301df7c53020d20b8fa7.tar.xz
Make sure output buffer is not full when filling it and detect end of input buffer properly.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/stm_misc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fitz/stm_misc.c b/fitz/stm_misc.c
index a95833b4..8e3ced42 100644
--- a/fitz/stm_misc.c
+++ b/fitz/stm_misc.c
@@ -46,7 +46,7 @@ static inline int fz_fillbuf(fz_stream *stm, fz_buffer *buf)
int remaining = buf->ep - buf->wp;
int available = stm->buffer->wp - stm->buffer->rp;
- if (available == 0)
+ if (available == 0 && remaining > 0)
{
int c = fz_readbytex(stm);
if (c == EOF)
@@ -62,7 +62,7 @@ static inline int fz_fillbuf(fz_stream *stm, fz_buffer *buf)
buf->wp += MIN(remaining, available);
stm->buffer->rp += MIN(remaining, available);
- if (buf->rp == buf->wp && stm->buffer->eof)
+ if (stm->buffer->rp == stm->buffer->wp && stm->buffer->eof)
return EOF;
return 0;
}