commit 4bcbd2534cdbdb24ab4e353ab5a83538f12780dc
parent f08500976663fe63aa81e0f6bd4f421e07b8d5c1
Author: nsz <nszabolcs@gmail.com>
Date: Tue, 9 Jun 2009 14:18:09 +0200
+check
Diffstat:
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -21,7 +21,7 @@ clean:
prof: inflate.c
gcc -O3 -fprofile-arcs -ftest-coverage -pg -g -Wall $<
- cat d.dat | ./a.out > /dev/null
+ cat a.dat | ./a.out > /dev/null
gcov -b $< > /dev/null
gprof a.out > $<.gprof
gcc -g -Wall $<
diff --git a/inflate.c b/inflate.c
@@ -45,7 +45,6 @@ enum {
DecodeBlockCopy
};
-
typedef struct {
short len; /* code length */
ushort sym; /* symbol */
@@ -151,8 +150,11 @@ static int build_huff(Huff *huff, uchar *lens, uint n, uint nbits) {
for (min = 1; min < CodeBits; min++)
if (count[min] != 0)
break;
- if (nbits < min)
+ if (nbits < min) {
nbits = min;
+ if (nbits > TableBits)
+ return -1;
+ }
huff->nbits = nbits;
/* check if length is over-subscribed or incomplete */