diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2017-04-05 12:14:40 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2017-04-05 12:14:40 +0100 |
commit | af6ab260260383f86b2dde2c2973ad59f7c42d05 (patch) | |
tree | 197f61d49fd579a48e5ba89e0f359954c22e701c | |
parent | 099b873abca6b868f159e16894f3640d40dca5aa (diff) | |
download | libnsgif-af6ab260260383f86b2dde2c2973ad59f7c42d05.tar.gz libnsgif-af6ab260260383f86b2dde2c2973ad59f7c42d05.tar.bz2 |
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
-rw-r--r-- | src/lzw.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -6,6 +6,7 @@ * Copyright 2017 Michael Drake <michael.drake@codethink.co.uk> */ +#include <assert.h> #include <stdint.h> #include <stdlib.h> #include <stdbool.h> @@ -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); |