diff options
-rw-r--r-- | source/fitz/filter-lzw.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/fitz/filter-lzw.c b/source/fitz/filter-lzw.c index e13b0ef0..16b5253a 100644 --- a/source/fitz/filter-lzw.c +++ b/source/fitz/filter-lzw.c @@ -87,7 +87,7 @@ next_lzwd(fz_stream *stm, int len) break; } - if (next_code >= NUM_CODES && code != LZW_CLEAR) + if (next_code > NUM_CODES && code != LZW_CLEAR) { fz_warn(stm->ctx, "missing clear code in lzw decode"); code = LZW_CLEAR; @@ -106,6 +106,12 @@ next_lzwd(fz_stream *stm, int len) { old_code = code; } + else if (next_code == NUM_CODES) + { + /* TODO: Ghostscript checks for a following LZW_CLEAR before tolerating */ + fz_warn(stm->ctx, "tolerating a single out of range code in lzw decode"); + next_code++; + } else if (code > next_code || next_code >= NUM_CODES) { fz_warn(stm->ctx, "out of range code encountered in lzw decode"); |