diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-08-11 14:28:24 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-08-11 14:28:24 +0000 |
commit | bb440c5d057cf8c9f38ab07bdd5d23a0b6192e74 (patch) | |
tree | 7e8bfe168abaa6938c483c298a7a59d1bdf1da0f /fitz | |
parent | 8ba627f03db7c54d782cb2f5c356a5ec08eb4619 (diff) | |
download | mupdf-bb440c5d057cf8c9f38ab07bdd5d23a0b6192e74.tar.xz |
Unstuff extra bytes read when the filters are closed instead of only when EOD is encountered.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/filt_faxd.c | 14 | ||||
-rw-r--r-- | fitz/filt_lzwd.c | 16 |
2 files changed, 14 insertions, 16 deletions
diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c index e4a81724..dd6ac9d0 100644 --- a/fitz/filt_faxd.c +++ b/fitz/filt_faxd.c @@ -549,7 +549,6 @@ readfaxd(fz_stream *stm, unsigned char *buf, int len) unsigned char *ep = buf + len; unsigned char *tmp; fz_error error; - int i; if (fax->stage == SDONE) return 0; @@ -692,12 +691,6 @@ eol: rtc: fax->stage = SDONE; - - /* try to put back any extra bytes we read */ - i = (32 - fax->bidx) / 8; - while (i--) - fz_unreadbyte(fax->chain); - return p - buf; } @@ -705,6 +698,13 @@ static void closefaxd(fz_stream *stm) { fz_faxd *fax = stm->state; + int i; + + /* if we read any extra bytes, try to put them back */ + i = (32 - fax->bidx) / 8; + while (i--) + fz_unreadbyte(fax->chain); + fz_close(fax->chain); fz_free(fax->ref); fz_free(fax->dst); diff --git a/fitz/filt_lzwd.c b/fitz/filt_lzwd.c index e55a8c28..ba1ddf62 100644 --- a/fitz/filt_lzwd.c +++ b/fitz/filt_lzwd.c @@ -64,13 +64,6 @@ static inline int fillbits(fz_lzwd *lzw) return 0; } -static inline void unstuff(fz_lzwd *lzw) -{ - int i = (32 - lzw->bidx) / 8; - while (i--) - fz_unreadbyte(lzw->chain); -} - static int readlzwd(fz_stream *stm, unsigned char *buf, int len) { @@ -92,7 +85,6 @@ readlzwd(fz_stream *stm, unsigned char *buf, int len) { if (lzw->bidx > 32 - lzw->codebits) { - unstuff(lzw); lzw->eod = 1; return p - buf; } @@ -104,7 +96,6 @@ readlzwd(fz_stream *stm, unsigned char *buf, int len) if (lzw->code == LZW_EOD) { - unstuff(lzw); lzw->eod = 1; return p - buf; } @@ -184,6 +175,13 @@ static void closelzwd(fz_stream *stm) { fz_lzwd *lzw = stm->state; + int i; + + /* if we read any extra bytes, try to put them back */ + i = (32 - lzw->bidx) / 8; + while (i--) + fz_unreadbyte(lzw->chain); + fz_close(lzw->chain); fz_free(lzw); } |