Slightly improve LZW_CLEAR handling. * src/lzw/ftzopen.c (ft_lzwstate_io) <FT_LZW_PHASE_CODE>: Ensure that subsequent (modulo garbage byte(s)) LZW_CLEAR codes are handled as clear codes. This also re-sets old_code and old_char to predictable values, which is a little better than using `random' ones if the code following LZW_CLEAR is invalid.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/ChangeLog b/ChangeLog
index 3076409..5b37e68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2011-09-11 Tomas Hoger <thoger@redhat.com>
+ Slightly improve LZW_CLEAR handling.
+
+ * src/lzw/ftzopen.c (ft_lzwstate_io) <FT_LZW_PHASE_CODE>:
+ Ensure that subsequent (modulo garbage byte(s)) LZW_CLEAR codes are
+ handled as clear codes. This also re-sets old_code and old_char to
+ predictable values, which is a little better than using `random'
+ ones if the code following LZW_CLEAR is invalid.
+
+2011-09-11 Tomas Hoger <thoger@redhat.com>
+
Add explicit LZW decompression stack size limit.
Stack larger than 1<<LZW_MAX_BITS is never needed if prefix table is
diff --git a/src/lzw/ftzopen.c b/src/lzw/ftzopen.c
index f55ee3a..d7a6457 100644
--- a/src/lzw/ftzopen.c
+++ b/src/lzw/ftzopen.c
@@ -321,11 +321,12 @@
/* why not LZW_FIRST-256 ? */
state->free_ent = ( LZW_FIRST - 1 ) - 256;
state->buf_clear = 1;
- c = ft_lzwstate_get_code( state );
- if ( c < 0 )
- goto Eof;
- code = (FT_UInt)c;
+ /* not quite right, but at least more predictable */
+ old_code = 0;
+ old_char = 0;
+
+ goto NextCode;
}
in_code = code; /* save code for later */