X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=dehuff.c;h=a7254692dd4f90deae10bc2fb571baf9952f26bb;hb=f6111465adacc2840f4cd25d55b3017cbf0593b2;hp=0a9fbbcf1a4bcf1b2eb9f413eca7f1784503397e;hpb=618548d1f2e076a3da21368e708cf887dcbd20d2;p=fjl diff --git a/dehuff.c b/dehuff.c index 0a9fbbc..a725469 100644 --- a/dehuff.c +++ b/dehuff.c @@ -2,13 +2,14 @@ #include #include +#include "bytesource.h" #include "dehuff.h" void reliable_read(raw_input_func_t* input_func, void* userdata, uint8_t* buf, size_t len) { while (len > 0) { ssize_t bytes_read = input_func(userdata, buf, len); - assert(bytes_read <= len); + assert(bytes_read <= (ssize_t)len); // TODO: We need better error handling here. setjmp()/longjmp() // should hopefully do the trick, but we need to take care for @@ -158,7 +159,7 @@ unsigned read_huffman_symbol_slow_path(const struct huffman_table* table, unsigned code = read_bits(source, 1); int i = 0; - while (code > table->maxcode[i] || table->maxcode[i] == -1) { + while (table->maxcode[i] == -1 || code > (unsigned)table->maxcode[i]) { possibly_refill(source, 1); code = (code << 1) | read_bits(source, 1); ++i;