From af6ab260260383f86b2dde2c2973ad59f7c42d05 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 5 Apr 2017 12:14:40 +0100 Subject: LZW decoder: Squash scan-build error by adding assert. Note, for scan-build to correctly interpret the assert, the library must be built in debug mode: $ scan-build-4.0 make VARIANT=debug --- src/lzw.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/lzw.c b/src/lzw.c index 6b7156e..6ad95aa 100644 --- a/src/lzw.c +++ b/src/lzw.c @@ -6,6 +6,7 @@ * Copyright 2017 Michael Drake */ +#include #include #include #include @@ -160,6 +161,8 @@ static inline lzw_result lzw__next_code( uint8_t current_bit = ctx->sb_bit & 0x7; uint8_t byte_advance = (current_bit + code_size) >> 3; + assert(byte_advance <= 2); + if (ctx->sb_bit + code_size < ctx->sb_bit_count) { /* Fast path: code fully inside this sub-block */ const uint8_t *data = ctx->sb_data + (ctx->sb_bit >> 3); -- cgit v1.2.3