summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);