commit 66633eca00f4329f7cb3f4fc635e8afb9f66b989
parent c289ca3da482ab0d0e8bca34550583fc39e5d41c
Author: nsz <nszabolcs@gmail.com>
Date: Wed, 22 Apr 2009 07:37:09 +0200
error check fix
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/inflate.c b/inflate.c
@@ -129,7 +129,7 @@ static int build_tree(HuffTree *t, const uchar *lens, int n) {
t->count[0] = 0;
/* check if length is over-subscribed or incomplete */
- for (left = i = 1; i <= HuffBits; i++) {
+ for (left = i = 1; i < HuffBits; i++) {
left <<= 1;
left -= t->count[i];
/* left < 0: over-subscribed, left > 0: incomplete */
@@ -373,9 +373,6 @@ void inflate_init(void) {
init_base_tables();
}
-#include <stdlib.h>
-#include <stdio.h>
-
/* inflate stream from src to dst */
uint inflate(void *dst, uint dstlen, void *src, uint srclen) {
FlateStream s;
@@ -393,7 +390,7 @@ uint inflate(void *dst, uint dstlen, void *src, uint srclen) {
final = getbit(&s);
blocktype = getbits(&s, 2);
if (s.error != FlateOk)
- return fprintf(stderr, "error: %d\n", s.error);
+ return 0;
/* decompress block */
switch (blocktype) {
@@ -410,12 +407,15 @@ uint inflate(void *dst, uint dstlen, void *src, uint srclen) {
s.error = FlateCorrupted;
}
if (s.error != FlateOk)
- return fprintf(stderr, "error: %d\n", s.error);
+ return 0;
} while (!final);
return s.dst - s.dstbegin;
}
+#include <stdlib.h>
+#include <stdio.h>
+
void *readall(char *name, uint *len) {
uint size = 1 << 22;
void *buf;