summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2021-03-31 20:18:43 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2021-03-31 20:18:43 +0100
commite6c790fc877a231653f92b70c75a456812b5be0d (patch)
treea1f4658e6c8d3bc9d6d3c3fb859f40d3f6bd7251
parent0d7049e414806b8af7f835cae9321138d4042a73 (diff)
downloadlibnsgif-e6c790fc877a231653f92b70c75a456812b5be0d.tar.gz
libnsgif-e6c790fc877a231653f92b70c75a456812b5be0d.tar.bz2
lzw: Avoid code size increment check when dictionary is full.
-rw-r--r--src/lzw.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lzw.c b/src/lzw.c
index 1d145b4..55bb4f8 100644
--- a/src/lzw.c
+++ b/src/lzw.c
@@ -357,11 +357,10 @@ lzw_result lzw_decode(struct lzw_ctx *ctx,
lzw__dictionary_add_entry(ctx, (code_new < current_entry) ?
table[code_new].first_value :
ctx->previous_code_first);
- }
- /* Ensure code size is increased, if needed. */
- if (current_entry == ctx->current_code_size_max) {
- if (ctx->current_code_size < LZW_CODE_MAX) {
+ /* Ensure code size is increased, if needed. */
+ if (current_entry == ctx->current_code_size_max &&
+ ctx->current_code_size < LZW_CODE_MAX) {
ctx->current_code_size++;
ctx->current_code_size_max =
(1 << ctx->current_code_size) - 1;