summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2017-04-05 11:14:40 (GMT)
committer Michael Drake <michael.drake@codethink.co.uk>2017-04-05 11:14:40 (GMT)
commitaf6ab260260383f86b2dde2c2973ad59f7c42d05 (patch)
tree197f61d49fd579a48e5ba89e0f359954c22e701c
parent099b873abca6b868f159e16894f3640d40dca5aa (diff)
downloadlibnsgif-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.c3
1 files changed, 3 insertions, 0 deletions
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 <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);