commit 87810d14c20e0d6357d001888993e2d9186fa23a
parent e2f5daebd4435fe354b86dc67a06de9f1b248797
Author: nsz <nszabolcs@gmail.com>
Date: Sat, 13 Jun 2009 17:54:29 +0200
inflate fix decode_symbol
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/inflate.c b/inflate.c
@@ -222,6 +222,7 @@ static void init_fixed_huffs(void) {
build_huff(&dhuff, lens, Ndist, 5);
}
+/* fill *bits with n bits from *src */
static int fillbits_fast(uchar **src, uchar *srcend, uint *bits, uint *nbits, uint n) {
while (*nbits < n) {
if (*src == srcend)
@@ -232,6 +233,7 @@ static int fillbits_fast(uchar **src, uchar *srcend, uint *bits, uint *nbits, ui
return 1;
}
+/* get n bits from *bits */
static uint getbits_fast(uint *bits, uint *nbits, int n) {
uint k;
@@ -319,6 +321,8 @@ static uint decode_symbol(State *s, Huff *huff) {
s->nbits = nbits - entry.len;
return entry.sym;
}
+ s->bits = bits;
+ s->nbits = nbits;
return FlateNeedInput;
}
bits |= *s->src++ << nbits;
@@ -347,7 +351,6 @@ static int decode_block(State *s, Huff *lhuff, Huff *dhuff) {
case DecodeBlock:
for (;;) {
sym = decode_symbol(s, lhuff);
-
if (sym < 256) {
win[pos++] = sym;
if (pos == WinSize) {
@@ -565,6 +568,7 @@ int inflate(State *s) {
s->state = DynamicHuffContinue;
return FlateNeedInput;
}
+ /* TODO: bound check s->lens */
if (sym == 16) {
/* copy previous code length 3-6 times */
c = s->lens[n - 1];