[gs-commits] mupdf/master - 0_6-273-g193b064 - Fix bugs in RunLengthDecode filter.

Tor Andersson tor at ghostscript.com
Wed Aug 18 13:10:42 UTC 2010


commit 193b064251b89f579180b2d9a3307227f0f2d731
Author: Tor Andersson <tor at ghostscript.com>
Date:   Wed Aug 18 12:38:33 2010 +0000

    Fix bugs in RunLengthDecode filter.
    
    Ignore-this: e66fda3b4fdb69efd5e186d80ef728c9
    
    darcs-hash:20100818123833-f546f-757f7289841ecb0ae9885e9b24dff03d99f5625d.gz

 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fitz/filt_basic.c b/fitz/filt_basic.c
index a036928..14eefb1 100644
--- a/fitz/filt_basic.c
+++ b/fitz/filt_basic.c
@@ -331,19 +331,23 @@ readrld(fz_stream *stm, unsigned char *buf, int len)
 
 		if (state->run < 128)
 		{
-			while (p < ep && state->n--)
+			while (p < ep && state->n)
 			{
 				int c = fz_readbyte(state->chain);
 				if (c < 0)
 					return fz_throw("premature end of data in run length decode");
 				*p++ = c;
+				state->n--;
 			}
 		}
 
 		if (state->run > 128)
 		{
-			while (p < ep && state->n--)
+			while (p < ep && state->n)
+			{
 				*p++ = state->c;
+				state->n--;
+			}
 		}
 	}
 
@@ -364,6 +368,7 @@ fz_openrld(fz_stream *chain)
 	fz_rld *state;
 
 	state = fz_malloc(sizeof(fz_rld));
+	state->chain = chain;
 	state->run = 0;
 	state->n = 0;
 	state->c = 0;

--
git/hooks/post-receive


More information about the gs-commits mailing list