summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2010-08-02 00:17:23 +0000
committerSebastian Rasmussen <sebras@hotmail.com>2010-08-02 00:17:23 +0000
commit28a4c167d90f07af0a77f71c397303731c00abe1 (patch)
treedf41a9a5d90e67dd5269a21be55832ce057ffa28
parent75a8fa28c53a9761936abbbb1b250299c76e8834 (diff)
downloadmupdf-28a4c167d90f07af0a77f71c397303731c00abe1.tar.xz
Fix bugs where pointer to remaining data in filters was not updated, also make all occurances of the code follow a common idiom.
-rw-r--r--fitz/filt_basic.c14
-rw-r--r--fitz/filt_faxd.c8
-rw-r--r--fitz/filt_lzwd.c4
3 files changed, 13 insertions, 13 deletions
diff --git a/fitz/filt_basic.c b/fitz/filt_basic.c
index 90be39ee..bac3dc23 100644
--- a/fitz/filt_basic.c
+++ b/fitz/filt_basic.c
@@ -25,7 +25,7 @@ readnull(fz_stream *stm, unsigned char *buf, int len)
if (n < 0)
return fz_rethrow(n, "read error in null filter");
state->remain -= n;
- return n;
+ return n;
}
static void
@@ -175,7 +175,7 @@ reada85d(fz_stream *stm, unsigned char *buf, int len)
int c;
while (state->remain > 0 && p < buf + len)
- *p++ = state->buf[4 - state->remain];
+ *p++ = state->buf[4 - state->remain--];
while (p < buf + len)
{
@@ -256,7 +256,7 @@ reada85d(fz_stream *stm, unsigned char *buf, int len)
}
while (state->remain > 0 && p < buf + len)
- *p++ = state->buf[4 - state->remain];
+ *p++ = state->buf[4 - state->remain--];
}
return p - buf;
@@ -435,8 +435,8 @@ readaesd(fz_stream *stm, unsigned char *buf, int len)
state->iv[state->ivcount++] = c;
}
- while (p < buf + len && state->remain-- > 0)
- *p++ = state->buf[16 - state->remain];
+ while (state->remain > 0 && p < buf + len)
+ *p++ = state->buf[16 - state->remain--];
while (p < buf + len)
{
@@ -463,8 +463,8 @@ readaesd(fz_stream *stm, unsigned char *buf, int len)
state->remain -= pad;
}
- while (p < buf + len && state->remain-- > 0)
- *p++ = state->buf[16 - state->remain];
+ while (state->remain > 0 && p < buf + len)
+ *p++ = state->buf[16 - state->remain--];
}
return p - buf;
diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c
index 57e206bf..e925a612 100644
--- a/fitz/filt_faxd.c
+++ b/fitz/filt_faxd.c
@@ -634,13 +634,13 @@ eol:
if (fax->blackis1)
{
- while (p < buf + len && fax->remain-- > 0)
- *p++ = fax->dst[fax->stride - fax->remain];
+ while (fax->remain > 0 && p < buf + len)
+ *p++ = fax->dst[fax->stride - fax->remain--];
}
else
{
- while (p < buf + len && fax->remain-- > 0)
- *p++ = fax->dst[fax->stride - fax->remain] ^ 0xff;
+ while (fax->remain > 0 && p < buf + len)
+ *p++ = fax->dst[fax->stride - fax->remain--] ^ 0xff;
}
if (fax->remain > 0)
diff --git a/fitz/filt_lzwd.c b/fitz/filt_lzwd.c
index 5e3c836e..5ec8093f 100644
--- a/fitz/filt_lzwd.c
+++ b/fitz/filt_lzwd.c
@@ -80,7 +80,7 @@ readlzwd(fz_stream *stm, unsigned char *buf, int len)
unsigned char *s;
while (lzw->remain > 0 && p < buf + len)
- *p++ = lzw->output[lzw->outlen - lzw->remain];
+ *p++ = lzw->output[lzw->outlen - lzw->remain--];
while (p < buf + len)
{
@@ -171,7 +171,7 @@ output:
/* copy to output */
while (lzw->remain > 0 && p < buf + len)
- *p++ = lzw->output[lzw->outlen - lzw->remain];
+ *p++ = lzw->output[lzw->outlen - lzw->remain--];
}
return p - buf;