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-04-05 14:51:52 +0100
commitce2543b41e3394c5cf3161d49f1561ba34f674a2 (patch)
treeb6694c0b39261511812190a37f0b36339a19505c
parent55c00227e1ad7cd7e03cc377fdaf052d57a56a06 (diff)
downloadlibnsgif-ce2543b41e3394c5cf3161d49f1561ba34f674a2.tar.gz
libnsgif-ce2543b41e3394c5cf3161d49f1561ba34f674a2.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;