From 12799e9be77c85eba11f70523d6ca9112266adae Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 2 Jul 2012 17:58:08 +0100 Subject: Prediction filter assumes it's writing to zeroed memory. The putcomponent function assumes the function has been cleared. Simple fix to clear bytes at the start of each scanline. Problem seen with normal_217.pdf --- fitz/filt_predict.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'fitz/filt_predict.c') diff --git a/fitz/filt_predict.c b/fitz/filt_predict.c index 5fbd7d1d..ebd712fd 100644 --- a/fitz/filt_predict.c +++ b/fitz/filt_predict.c @@ -63,9 +63,11 @@ fz_predict_tiff(fz_predict *state, unsigned char *out, unsigned char *in, int le { int left[MAXC]; int i, k; + const int mask = (1 << state->bpc)-1; for (k = 0; k < state->colors; k++) left[k] = 0; + memset(out, 0, state->stride); for (i = 0; i < state->columns; i++) { @@ -73,7 +75,7 @@ fz_predict_tiff(fz_predict *state, unsigned char *out, unsigned char *in, int le { int a = getcomponent(in, i * state->colors + k, state->bpc); int b = a + left[k]; - int c = b % (1 << state->bpc); + int c = b & mask; putcomponent(out, i * state->colors + k, state->bpc, c); left[k] = c; } -- cgit v1.2.3