X-Git-Url: https://git.sesse.net/?p=fjl;a=blobdiff_plain;f=dehuff.c;h=9b296a798075bf6f6f01e2bd439c8c4b7da1bba2;hp=0a9fbbcf1a4bcf1b2eb9f413eca7f1784503397e;hb=0b02847989970a190c2cfaec4d1abaa1f616284a;hpb=618548d1f2e076a3da21368e708cf887dcbd20d2 diff --git a/dehuff.c b/dehuff.c index 0a9fbbc..9b296a7 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 @@ -34,7 +35,7 @@ uint16_t read_length(raw_input_func_t* input_func, void* userdata) return (buf[0] << 8) | buf[1]; } -void read_huffman_tables(huffman_tables_t* dst, raw_input_func_t* input_func, void* userdata) +void read_huffman_tables(huffman_tables_t* dst, input_func_t* input_func, void* userdata) { size_t len = read_length(input_func, userdata); assert(len > 2); @@ -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;